statement
stringlengths
1
8.57k
proof
stringlengths
0
182k
type
stringclasses
13 values
symbolic_name
stringlengths
1
89
library
stringclasses
73 values
filename
stringlengths
14
95
imports
listlengths
0
0
deps
listlengths
0
64
docstring
stringclasses
1 value
source_url
stringclasses
1 value
commit
stringclasses
1 value
hint2 : t:(seq int) -> a:int -> mid:int -> Lemma (requires (forall i1 i2. {:pattern index t i1; index t i2} (0 <= i1) ==> (i1 <= i2) ==> (i2 < length t) ==> (index t i1 <= index t i2)) /\ (0 <= mid) /\ (mid < length t) /\ (index t mid < a)) ...
val
hint2
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "Lemma", "i2", "index", "int", "length", "pattern", "seq" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
hint2 t a mid
= ()
let
hint2
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
hint3 : y:int -> a:int -> Lemma (requires True) (ensures (forall x. (((y <= x) /\ (a < y) /\ (x = a)) ==> False)))
val
hint3
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "Lemma", "int" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
hint3 y a
= ()
let
hint3
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
hint4 : t:(seq int) -> a:int -> mid:int -> Lemma (requires (forall i1 i2. {:pattern index t i1; index t i2} (0 <= i1) ==> (i1 <= i2) ==> (i2 < length t) ==> (index t i1 <= index t i2)) /\ (0 <= mid) /\ (mid < length t) /\ (a < index t mid)) ...
val
hint4
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "Lemma", "i2", "index", "int", "length", "pattern", "seq" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
hint4 t a mid
= hint3 (index t mid) a
let
hint4
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "hint3", "index" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
bsearch_rec_complete : t:(seq int) -> a:int -> i:nat{i <= length t} -> j:int{-1 <= j /\ j < length t} -> Lemma (requires (forall i1 i2. (0 <= i1) ==> (i1 <= i2) ==> (i2 < length t) ==> (index t i1 <= index t i2)) /\ (forall p. 0...
val
bsearch_rec_complete
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "Lemma", "bsearch_rec", "i2", "index", "int", "length", "nat", "seq" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec bsearch_rec_complete t a i j
= if i > j then () else let mid = (i + j)/2 in let b = index t mid in if b = a then (* a = b *) () else if b < a then ( (* b < a *) hint2 t a mid; bsearch_rec_complete t a (mid+1) j ) else ( (* a < b *) hint4 t a mid; bsea...
let
bsearch_rec_complete
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "hint2", "hint4", "index" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
bsearch_complete : t:(seq int) -> a:int -> Lemma (requires (forall i1 i2. (0 <= i1) ==> (i1 <= i2) ==> (i2 < length t) ==> (index t i1 <= index t i2))) (ensures ((None? (bsearch t a)) ==> (forall p. 0 <= p ==> p < length t ==> index t p <> a)))
val
bsearch_complete
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "Lemma", "bsearch", "i2", "index", "int", "length", "seq" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
bsearch_complete t a
= bsearch_rec_complete t a 0 ((length t)-1)
let
bsearch_complete
examples.algorithms
examples/algorithms/BinarySearch.fst
[]
[ "bsearch_rec_complete", "length" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
mem: int -> list int -> Tot bool
val
mem
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[ "Tot", "bool", "int", "list" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec mem a l
= match l with | [] -> false | hd::tl -> hd=a || mem a tl
let
mem
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[ "hd", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sorted: list int -> Tot bool
val
sorted
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[ "Tot", "bool", "int", "list" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec sorted l
= match l with | x::y::xs -> x < y && sorted (y::xs) | _ -> true
let
sorted
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
lemma1 : y:int -> xs:list int -> Lemma (requires (sorted xs && (xs = [] || y < Cons?.hd xs))) (ensures (not (mem y xs)))
val
lemma1
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[ "Lemma", "hd", "int", "list", "mem", "sorted" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec lemma1 y xs
= match xs with | [] -> () | x::xs' -> lemma1 y xs'
let
lemma1
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
coincidence : xs:(list int){sorted xs} -> ys : (list int){sorted ys} -> Tot (zs:(list int){forall z. mem z zs <==> (mem z xs && mem z ys)})
val
coincidence
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[ "Tot", "int", "list", "mem", "sorted" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec coincidence xs ys
= match xs, ys with | x::xs', y::ys' -> if x = y then x :: coincidence xs' ys' else if x < y then (lemma1 x ys; coincidence xs' ys) else (lemma1 y xs; coincidence xs ys') | _ -> []
let
coincidence
examples.algorithms
examples/algorithms/Coincidence.fst
[]
[ "lemma1" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
color
= | Unalloc | White | Gray | Black
type
color
examples.algorithms
examples/algorithms/GC.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
mem_lo : x:int{0 < x}
assume val
mem_lo
examples.algorithms
examples/algorithms/GC.fst
[]
[ "int" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
mem_hi : x:int{mem_lo < x}
assume val
mem_hi
examples.algorithms
examples/algorithms/GC.fst
[]
[ "int", "mem_lo" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
is_mem_addr i
= mem_lo <= i && i < mem_hi
let
is_mem_addr
examples.algorithms
examples/algorithms/GC.fst
[]
[ "mem_hi", "mem_lo" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
field
= | F1 | F2
type
field
examples.algorithms
examples/algorithms/GC.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
abs_node : a:Type0{hasEq a}
assume type
abs_node
examples.algorithms
examples/algorithms/GC.fst
[]
[ "hasEq" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
no_abs : abs_node
assume val
no_abs
examples.algorithms
examples/algorithms/GC.fst
[]
[ "abs_node" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
valid a
= a <> no_abs
let
valid
examples.algorithms
examples/algorithms/GC.fst
[]
[ "no_abs" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
valid_node
= a:abs_node{valid a}
type
valid_node
examples.algorithms
examples/algorithms/GC.fst
[]
[ "abs_node", "valid" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
mem_addr
= i:int{is_mem_addr i}
type
mem_addr
examples.algorithms
examples/algorithms/GC.fst
[]
[ "int", "is_mem_addr" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
color_map
= mem_addr -> Tot color
type
color_map
examples.algorithms
examples/algorithms/GC.fst
[]
[ "Tot", "color", "mem_addr" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
abs_map
= mem_addr -> Tot abs_node
type
abs_map
examples.algorithms
examples/algorithms/GC.fst
[]
[ "Tot", "abs_node", "mem_addr" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
field_map
= mem_addr & field -> Tot mem_addr
type
field_map
examples.algorithms
examples/algorithms/GC.fst
[]
[ "Tot", "field", "mem_addr" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
abs_field_map
= abs_node & field -> Tot abs_node
type
abs_field_map
examples.algorithms
examples/algorithms/GC.fst
[]
[ "Tot", "abs_node", "field" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
trigger (i:int)
= True
type
trigger
examples.algorithms
examples/algorithms/GC.fst
[]
[ "int" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
to_abs_inj (to_abs:abs_map)
= forall (i1:mem_addr) (i2:mem_addr).{:pattern (trigger i1); (trigger i2)} trigger i1 /\ trigger i2 /\ valid (to_abs i1) /\ valid (to_abs i2) /\ i1 <> i2 ==> to_abs i1 <> to_abs i2
type
to_abs_inj
examples.algorithms
examples/algorithms/GC.fst
[]
[ "abs_map", "i2", "mem_addr", "pattern", "trigger", "valid" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
gc_state
= { to_abs: abs_map; color: color_map; abs_fields: abs_field_map; fields: field_map }
type
gc_state
examples.algorithms
examples/algorithms/GC.fst
[]
[ "abs_field_map", "abs_map", "color", "color_map", "field_map" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
ptr_lifts gc_state (ptr:mem_addr) : prop
= b2t (valid (gc_state.to_abs ptr))
type
ptr_lifts
examples.algorithms
examples/algorithms/GC.fst
[]
[ "b2t", "gc_state", "mem_addr", "prop", "ptr", "valid" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
ptr_lifts_to gc_state (ptr:mem_addr) (abs:abs_node) : prop
= valid abs /\ gc_state.to_abs ptr = abs
type
ptr_lifts_to
examples.algorithms
examples/algorithms/GC.fst
[]
[ "abs", "abs_node", "gc_state", "mem_addr", "prop", "ptr", "valid" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
obj_inv gc_state (i:mem_addr) : prop
= valid (gc_state.to_abs i) ==> (forall f. ptr_lifts_to gc_state (gc_state.fields (i, f)) (gc_state.abs_fields (gc_state.to_abs i, f)))
type
obj_inv
examples.algorithms
examples/algorithms/GC.fst
[]
[ "gc_state", "mem_addr", "prop", "ptr_lifts_to", "valid" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
inv gc_state (color_invariant:mem_addr -> prop) : prop
= to_abs_inj gc_state.to_abs /\ (forall (i:mem_addr).{:pattern (trigger i)} trigger i ==> obj_inv gc_state i /\ color_invariant i /\ (not (valid (gc_state.to_abs i)) <==> gc_state.color i = Unalloc))
type
inv
examples.algorithms
examples/algorithms/GC.fst
[]
[ "gc_state", "mem_addr", "obj_inv", "pattern", "prop", "to_abs_inj", "trigger", "valid" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
gc_inv gc_state
= inv gc_state (fun i -> (gc_state.color i = Black ==> (forall f. gc_state.color (gc_state.fields (i, f)) <> White)))
type
gc_inv
examples.algorithms
examples/algorithms/GC.fst
[]
[ "gc_state", "inv" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
mutator_inv gc_state
= inv gc_state (fun i -> gc_state.color i = Unalloc \/ gc_state.color i = White)
type
mutator_inv
examples.algorithms
examples/algorithms/GC.fst
[]
[ "gc_state", "inv" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
GC_STATE = STATE_h gc_state
new_effect
GC_STATE
examples.algorithms
examples/algorithms/GC.fst
[]
[ "STATE_h", "gc_state" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
gc_post (a:Type)
= a -> gc_state -> prop sub_effect DIV ~> GC_STATE = fun (a:Type) (wp:pure_wp a) (p:gc_post a) (gc:gc_state) -> wp (fun a -> p a gc)
let
gc_post
examples.algorithms
examples/algorithms/GC.fst
[]
[ "DIV", "GC_STATE", "gc", "gc_state", "prop", "pure_wp", "wp" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
GC (a:Type) (pre:gc_state -> prop) (post: gc_state -> Tot (gc_post a)) = GC_STATE a (fun (p:gc_post a) (gc:gc_state) -> pre gc /\ (forall a gc'. (pre gc /\ post gc a gc') ==> p a gc'))
effect
GC
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC_STATE", "Tot", "gc", "gc_post", "gc_state", "post", "pre", "prop" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
GCMut (res:Type) (req:gc_state -> prop) (ens:gc_state -> Tot (gc_post res)) = GC res (fun gc -> req gc /\ mutator_inv gc) (fun gc res gc' -> ens gc res gc' /\ mutator_inv gc')
effect
GCMut
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "Tot", "gc", "gc_post", "gc_state", "mutator_inv", "prop", "res" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
get : unit -> GC gc_state (fun gc -> True) (fun gc res gc' -> gc==gc' /\ res==gc')
assume val
get
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "gc", "gc_state", "res", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
set : g:gc_state -> GC unit (fun gc -> True) (fun _ _ gc' -> g==gc')
assume val
set
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "gc", "gc_state", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
init_invariant (ptr:mem_addr) (gc:gc_state) : prop
= forall i. mem_lo <= i /\ i < ptr ==> not(valid (gc.to_abs i)) /\ gc.color i = Unalloc
type
init_invariant
examples.algorithms
examples/algorithms/GC.fst
[]
[ "gc", "gc_state", "mem_addr", "mem_lo", "prop", "ptr", "valid" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
upd_map: #a:eqtype -> #b:Type -> (a -> Tot b) -> a -> b -> a -> Tot b
val
upd_map
examples.algorithms
examples/algorithms/GC.fst
[]
[ "Tot", "eqtype" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
upd_map #a #b f i v
= fun j -> if i=j then v else f j
let
upd_map
examples.algorithms
examples/algorithms/GC.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
upd_map2: #a:eqtype -> #b:eqtype -> #c:Type -> (a -> b -> Tot c) -> a -> b -> c -> a -> b -> Tot c
val
upd_map2
examples.algorithms
examples/algorithms/GC.fst
[]
[ "Tot", "eqtype" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
upd_map2 #a #b #c m i f v
= fun j g -> if (i,f)=(j,g) then v else m j g
let
upd_map2
examples.algorithms
examples/algorithms/GC.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
initialize: unit -> GC unit (requires (fun g -> True)) (ensures (fun g _ g' -> mutator_inv g'))
val
initialize
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "g'", "mutator_inv", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
initialize ()
= let rec aux_init : ptr:mem_addr -> GC unit (requires (init_invariant ptr)) (ensures (fun gc _ gc' -> mutator_inv gc')) = fun ptr -> let gc = get () in let gc' = {gc with color=upd_map gc.color ptr Unalloc; ...
let
initialize
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "color", "gc", "get", "init_invariant", "mem_addr", "mem_hi", "mem_lo", "mutator_inv", "no_abs", "ptr", "set", "unit", "upd_map" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
read_field : ptr:mem_addr -> f:field -> GCMut mem_addr (requires (fun gc -> ptr_lifts_to gc ptr (gc.to_abs ptr))) (ensures (fun gc i gc' -> gc==gc' /\ ptr_lifts_to gc' i (gc.abs_fields (gc.to_abs ptr, f))))
val
read_field
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GCMut", "field", "gc", "mem_addr", "ptr", "ptr_lifts_to" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
read_field ptr f
= cut (trigger ptr); let gc = get () in gc.fields (ptr, f)
let
read_field
examples.algorithms
examples/algorithms/GC.fst
[]
[ "cut", "gc", "get", "ptr", "trigger" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
write_field: ptr:mem_addr -> f:field -> v:mem_addr -> GCMut unit (requires (fun gc -> ptr_lifts gc ptr /\ ptr_lifts gc v)) (ensures (fun gc _ gc' -> gc'.color==gc.color))
val
write_field
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GCMut", "field", "gc", "mem_addr", "ptr", "ptr_lifts", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
write_field ptr f v
= cut (trigger ptr /\ trigger v); let gc = get () in let gc' = {gc with fields=upd_map gc.fields (ptr, f) v; abs_fields=upd_map gc.abs_fields (gc.to_abs ptr, f) (gc.to_abs v); } in set gc'
let
write_field
examples.algorithms
examples/algorithms/GC.fst
[]
[ "cut", "gc", "get", "ptr", "set", "trigger", "upd_map" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
mark : ptr:mem_addr -> GC unit (requires (fun gc -> gc_inv gc /\ trigger ptr /\ ptr_lifts gc ptr)) (ensures (fun gc _ gc' -> gc_inv gc' /\ (forall (i:mem_addr).{:pattern (trigger i)} trigger i ==> (gc'.color i <> Black ...
val
mark
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "color", "gc", "gc_inv", "mem_addr", "pattern", "ptr", "ptr_lifts", "trigger", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec mark ptr
= let st = get () in if st.color ptr = White then begin let st' = {st with color=upd_map st.color ptr Gray} in set st'; mark (st'.fields (ptr, F1)); mark (st'.fields (ptr, F2)); let st'' = get () in set ({st'' with color = upd_map st''.color ptr Black}) end type sweep_aux_inv (old:gc_...
let
mark
examples.algorithms
examples/algorithms/GC.fst
[]
[ "color", "gc_inv", "gc_state", "get", "int", "mem_addr", "obj_inv", "old", "pattern", "ptr", "ptr_lifts", "set", "st", "to_abs_inj", "trigger", "upd_map" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
test1 old n
= assert (sweep_aux_inv old mem_hi n ==> mutator_inv n)
let
test1
examples.algorithms
examples/algorithms/GC.fst
[]
[ "mem_hi", "mutator_inv", "old" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
test2 old
= assert (gc_inv old /\ (forall i. old.color i <> Gray) ==> sweep_aux_inv old mem_lo old)
let
test2
examples.algorithms
examples/algorithms/GC.fst
[]
[ "gc_inv", "mem_lo", "old" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sweep: unit -> GC unit (requires (fun gc -> gc_inv gc /\ (forall (i:mem_addr). {:pattern (trigger i)} trigger i ==> gc.color i <> Gray))) (ensures (fun gc _ gc' -> (exists c a. gc' == {gc with color=c; to_abs=a} /\ mu...
val
sweep
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "color", "gc", "gc_inv", "mem_addr", "mutator_inv", "pattern", "ptr_lifts", "trigger", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sweep ()
= let old = get () in let rec sweep_aux : ptr:mem_addr -> GC unit (requires (fun gc -> sweep_aux_inv old ptr gc)) (ensures (fun _ _ st -> (st.abs_fields == old.abs_fields /\ st.fields == old.fields /\ mutator_inv st ...
let
sweep
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GC", "color", "cut", "gc", "get", "mem_addr", "mem_hi", "mem_lo", "mutator_inv", "no_abs", "old", "pattern", "ptr", "ptr_lifts", "set", "st", "trigger", "unit", "upd_map" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
gc: root:mem_addr -> GCMut unit (requires (fun gc -> root<>0 ==> ptr_lifts gc root)) (ensures (fun gc _ gc' -> (exists c a. gc' == {gc with color=c; to_abs=a}) /\ (root<>0 ==> ptr_lifts gc' root) /\ (forall (i:mem_addr). {:pattern (trigger i)} ...
val
gc
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GCMut", "color", "mem_addr", "pattern", "ptr_lifts", "trigger", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
gc root
= cut (trigger root); if (root <> 0) then mark root; sweep ()
let
gc
examples.algorithms
examples/algorithms/GC.fst
[]
[ "cut", "mark", "sweep", "trigger" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
try_alloc_invariant (root:mem_addr) (abs:abs_node) (gc:gc_state) (gc':gc_state)
= (root <> 0 ==> ptr_lifts_to gc' root (gc.to_abs root)) /\ gc'.abs_fields (abs, F1) = abs /\ gc'.abs_fields (abs, F2) = abs /\ (forall (i:mem_addr).{:pattern (trigger i)} trigger i ==> (ptr_lifts gc i ==> gc'.to_abs i <> abs))
type
try_alloc_invariant
examples.algorithms
examples/algorithms/GC.fst
[]
[ "abs", "abs_node", "gc", "gc_state", "mem_addr", "pattern", "ptr_lifts", "ptr_lifts_to", "trigger" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
alloc: root:mem_addr -> abs:abs_node -> GCMut mem_addr (requires (fun gc -> try_alloc_invariant root abs gc gc /\ abs <> no_abs /\ (forall (i:mem_addr). trigger i /\ ptr_lifts gc i ==> gc.to_abs i <> abs))) (ensures (fun gc ptr gc' -> (root <> 0 ==> ptr_lifts_to gc' root (g...
val
alloc
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GCMut", "abs", "abs_node", "gc", "mem_addr", "no_abs", "ptr", "ptr_lifts", "ptr_lifts_to", "trigger", "try_alloc_invariant" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec alloc root abs
= let rec try_alloc_at_ptr : ptr:mem_addr -> abs:abs_node -> GCMut int (requires (fun gc -> abs <> no_abs /\ trigger ptr /\ (forall (i:mem_addr). trigger i /\ ptr_lifts gc i ==> gc.to_abs i <> abs) /\ gc.abs_fields (abs, F1) = abs /\ ...
let
alloc
examples.algorithms
examples/algorithms/GC.fst
[]
[ "GCMut", "abs", "abs_node", "color", "field", "gc", "get", "int", "is_mem_addr", "mem_addr", "mem_hi", "mem_lo", "no_abs", "ptr", "ptr_lifts", "set", "trigger", "upd_map" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sorted: list 'a -> key:('a -> Tot int) -> Tot bool
val
sorted
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "Tot", "bool", "int", "key", "list" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec sorted l key
= match l with | [] | [_] -> true | x::y::xs -> (key x <= key y) && (sorted (y::xs) key)
let
sorted
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "key" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
test_sorted: x:'a -> l:list 'a -> key:('a -> Tot int) -> Lemma ((sorted (x::l) key /\ Cons? l) ==> key x <= key (Cons?.hd l))
val
test_sorted
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "Lemma", "Tot", "hd", "int", "key", "list", "sorted" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
test_sorted x l key
= ()
let
test_sorted
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "key" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
test_sorted2: unit -> key:('a -> Tot int) -> Tot (m:list 'a{sorted m key})
val
test_sorted2
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "Tot", "int", "key", "list", "sorted", "unit" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
test_sorted2 () key
= Nil
let
test_sorted2
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "key" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sorted_smaller: #a:eqtype -> x:a -> y:a -> l:list a -> key:(a -> Tot int) -> Lemma (requires (sorted (x::l) key /\ mem y l)) (ensures (key x <= key y)) [SMTPat (sorted (x::l) key); SMTP...
val
sorted_smaller
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "Lemma", "Tot", "eqtype", "int", "key", "list", "mem", "sorted" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec sorted_smaller #a x y l key
= match l with | [] -> () | z::zs -> if key z = key y then () else sorted_smaller x y zs key
let
sorted_smaller
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "key" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sorted_tl: #a:eqtype -> l:list a{Cons? l} -> k:(a -> Tot int) -> Lemma (requires (sorted l k)) (ensures (sorted (Cons?.tl l) k))
val
sorted_tl
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "Lemma", "Tot", "eqtype", "int", "list", "sorted", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec sorted_tl #a l k
= match l with | [_] -> () | a::b::xs -> sorted_tl (b::xs) k
let
sorted_tl
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sorted_lt: #a:eqtype -> l:list a{Cons? l} -> k:(a -> Tot int) -> Lemma (requires (sorted l k)) (ensures (forall x y. (x < k (hd l) /\ k y = x) ==> (mem y l = false)))
val
sorted_lt
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "Lemma", "Tot", "eqtype", "hd", "int", "list", "mem", "sorted" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
sorted_lt #a l k
= ()
let
sorted_lt
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
permutation (#a:Type{hasEq a}) (l1:list a) (l2:list a)
= length l1 = length l2 /\ (forall n. mem n l1 = mem n l2)
type
permutation
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "hasEq", "l1", "l2", "length", "list", "mem" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
permutation_2 (#a:Type{hasEq a}) (l:list a) (l1:list a) (l2:list a)
= (forall n. mem n l = (mem n l1 || mem n l2)) /\ length l = length l1 + length l2
type
permutation_2
examples.algorithms
examples/algorithms/GenericSort.fst
[]
[ "hasEq", "l1", "l2", "length", "list", "mem" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq: #a:Type -> (x:int) -> (xs: list a) -> k:(a -> Tot int) -> Tot (list a)
val
filter_eq
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Tot", "int", "list" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec filter_eq #a x xs k
= match xs with | [] -> [] | hd::tl -> if k hd = x then hd::(filter_eq x tl k) else filter_eq x tl k
let
filter_eq
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "hd", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_contains: #a:eqtype -> (k:int) -> (xs: list a) -> key:(a -> Tot int) -> Lemma (ensures (forall x. (mem x xs /\ key x = k) <==> mem x (filter_eq k xs key)))
val
filter_eq_contains
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Lemma", "Tot", "eqtype", "filter_eq", "int", "key", "list", "mem" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec filter_eq_contains #a k xs key
= match xs with | [] -> () | hd::tl -> filter_eq_contains k tl key
let
filter_eq_contains
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "hd", "key", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_append: #a:eqtype -> (l1: list a) -> (l2: list a) -> k:(a -> Tot int) -> Lemma (ensures (forall x. (filter_eq x l1 k)@(filter_eq x l2 k) = filter_eq x (l1@l2) k))
val
filter_eq_append
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Lemma", "Tot", "eqtype", "filter_eq", "int", "l1", "l2", "list" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec filter_eq_append #a l1 l2 k
= match l1 with | [] -> () | hd::tl -> filter_eq_append tl l2 k
let
filter_eq_append
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "hd", "l1", "l2", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_not_contains: #a:eqtype -> (l: list a) -> k:(a -> Tot int) -> Lemma (ensures (forall x. (filter_eq x l k) = [] <==> ~(exists e. (mem e l /\ k e = x))))
val
filter_eq_not_contains
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Lemma", "Tot", "eqtype", "filter_eq", "int", "list", "mem" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
rec filter_eq_not_contains #a l k
= match l with | [] -> () | hd::tl -> filter_eq_not_contains tl k
let
filter_eq_not_contains
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "hd", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_single: #a:eqtype -> (l: list a{Cons? l /\ length l = 1}) -> k:(a -> Tot int) -> Lemma (ensures (forall x. (k (hd l) = x ) ==> filter_eq x l k = [hd l]))
val
filter_eq_single
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Lemma", "Tot", "eqtype", "filter_eq", "hd", "int", "length", "list" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_single #a l k
= ()
let
filter_eq_single
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_sorted_lt: #a:eqtype -> l:list a{Cons? l} -> k:(a -> Tot int) -> Lemma (requires (sorted l k)) (ensures (forall x. (x < k (hd l)) ==> (filter_eq x l k = [])))
val
filter_eq_sorted_lt
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Lemma", "Tot", "eqtype", "filter_eq", "hd", "int", "list", "sorted" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_sorted_lt #a l k
= sorted_lt l k; filter_eq_not_contains l k
let
filter_eq_sorted_lt
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "filter_eq_not_contains", "sorted_lt" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_first: #a:eqtype -> (l1: list a{Cons? l1}) -> (l2: list a{Cons? l2}) -> k:(a -> Tot int) -> Lemma (requires (sorted l1 k) /\ (k (hd l1) > k (hd l2))) (ensures (forall x. (k (hd l2) = x ) ==> filter_eq x (l1@l2) k = ((filter_eq x ((hd l2)::l1) k )@(filter_eq x (tl l2) k))))
val
filter_eq_first
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Lemma", "Tot", "eqtype", "filter_eq", "hd", "int", "l1", "l2", "list", "sorted", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
filter_eq_first #a l1 l2 k
= filter_eq_append l1 l2 k; filter_eq_sorted_lt l1 k
let
filter_eq_first
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "filter_eq_append", "filter_eq_sorted_lt", "l1", "l2" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
stable (#a:eqtype) (l1:list a) (l2:list a) (k:(a -> Tot int))
= forall x. (filter_eq x l1 k = filter_eq x l2 k)
type
stable
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Tot", "eqtype", "filter_eq", "int", "l1", "l2", "list" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
stable_lift: #a:eqtype -> (l1: list a{Cons? l1}) -> (l2: list a{Cons? l2}) -> k:(a -> Tot int) -> Lemma (requires (sorted l1 k) /\ (k (hd l1) > k (hd l2))) (ensures (stable (l1@l2) (((hd l2)::l1)@(tl l2)) k))
val
stable_lift
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "Lemma", "Tot", "eqtype", "hd", "int", "l1", "l2", "list", "sorted", "stable", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee
stable_lift #a l1 l2 k
= filter_eq_append l1 l2 k; filter_eq_append ((hd l2)::l1) (tl l2) k; filter_eq_first l1 l2 k; filter_eq_append ((hd l2)::l1) (tl l2) k
let
stable_lift
examples.algorithms
examples/algorithms/GenericStability.fst
[]
[ "filter_eq_append", "filter_eq_first", "hd", "l1", "l2", "tl" ]
https://github.com/FStarLang/FStar
24f4d85a6adb3cd9cbc8100c3f4b6d89d0c6bdee