Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-place merge sort for slices #248

Merged
merged 9 commits into from
Nov 19, 2024
2 changes: 1 addition & 1 deletion lib/pulse/lib/Pulse.Lib.ArrayPtr.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ without modifying the pointer.
Use `Pulse.Lib.Slice.slice` instead when possible.
*)

val ptr : Type0 -> Type0
val ptr ([@@@strictly_positive] elt: Type0) : Type0

val base #t (p: ptr t) : GTot (A.array t)
val offset #t (p: ptr t) : GTot nat
Expand Down
2 changes: 1 addition & 1 deletion lib/pulse/lib/Pulse.Lib.Slice.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ open Pulse.Lib.Pervasives
module SZ = FStar.SizeT
module A = Pulse.Lib.Array

val slice : Type0 -> Type0
val slice ([@@@strictly_positive] elt: Type0) : Type0

val len (#t: Type) : slice t -> SZ.t

Expand Down
21 changes: 21 additions & 0 deletions lib/pulse/lib/Pulse.Lib.Sort.Base.fst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Pulse.Lib.Sort.Base
open Pulse.Lib.Pervasives

module I16 = FStar.Int16

inline_for_extraction
let impl_compare_t
(#tl #th: Type)
(vmatch: tl -> th -> slprop)
(compare: th -> th -> int)
= (x1: tl) ->
(x2: tl) ->
(#y1: Ghost.erased th) ->
(#y2: Ghost.erased th) ->
stt I16.t
(vmatch x1 y1 ** vmatch x2 y2)
(fun res -> vmatch x1 y1 ** vmatch x2 y2 ** pure (
let v = compare y1 y2 in
(v < 0 <==> I16.v res < 0) /\
(v > 0 <==> I16.v res > 0)
))
Loading
Loading