effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
val map (a:eqtype) (b:Type u#a) : Type u#a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let map = map'
val map (a:eqtype) (b:Type u#a) : Type u#a let map =
false
null
false
map'
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Vale.Lib.MapTree.map'" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx) = lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi #pop-options (** Map interface *) #push-options "--max_fuel 1 --max_ifuel 2" noeq type map' (a:eqtype) b = | Map : is_le:(a -> a -> bool) -> t:tree a b -> default_v:b -> invs:squash (is_cmp is_le /\ inv is_le t None None) -> map' a b #pop-options
false
true
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val map (a:eqtype) (b:Type u#a) : Type u#a
[]
Vale.Lib.MapTree.map
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.eqtype -> b: Type -> Type
{ "end_col": 14, "end_line": 144, "start_col": 10, "start_line": 144 }
Prims.Tot
val mkNode (#a: eqtype) (#b: Type) (key: a) (value: b) (l r: tree a b) : tree a b
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r
val mkNode (#a: eqtype) (#b: Type) (key: a) (value: b) (l r: tree a b) : tree a b let mkNode (#a: eqtype) (#b: Type) (key: a) (value: b) (l r: tree a b) : tree a b =
false
null
false
let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Vale.Lib.MapTree.tree", "Vale.Lib.MapTree.Node", "Prims.op_Addition", "Prims.int", "Prims.op_GreaterThan", "Prims.bool", "Prims.nat", "Vale.Lib.MapTree.height" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mkNode (#a: eqtype) (#b: Type) (key: a) (value: b) (l r: tree a b) : tree a b
[]
Vale.Lib.MapTree.mkNode
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: a -> value: b -> l: Vale.Lib.MapTree.tree a b -> r: Vale.Lib.MapTree.tree a b -> Vale.Lib.MapTree.tree a b
{ "end_col": 28, "end_line": 19, "start_col": 78, "start_line": 15 }
Prims.Tot
val height (#a: eqtype) (#b: Type) (t: tree a b) : nat
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h
val height (#a: eqtype) (#b: Type) (t: tree a b) : nat let height (#a: eqtype) (#b: Type) (t: tree a b) : nat =
false
null
false
match t with | Empty -> 0 | Node _ _ h _ _ -> h
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Vale.Lib.MapTree.tree", "Prims.nat" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val height (#a: eqtype) (#b: Type) (t: tree a b) : nat
[]
Vale.Lib.MapTree.height
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Vale.Lib.MapTree.tree a b -> Prims.nat
{ "end_col": 23, "end_line": 13, "start_col": 2, "start_line": 11 }
Prims.Tot
val sel (#a:eqtype) (#b:Type) (m:map a b) (key:a) : b
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel #a #b (Map is_le t d _) key = match get is_le t key with Some v -> v | None -> d
val sel (#a:eqtype) (#b:Type) (m:map a b) (key:a) : b let sel #a #b (Map is_le t d _) key =
false
null
false
match get is_le t key with | Some v -> v | None -> d
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Vale.Lib.MapTree.map", "Prims.bool", "Vale.Lib.MapTree.tree", "Prims.squash", "Prims.l_and", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.inv", "FStar.Pervasives.Native.None", "Vale.Lib.MapTree.get" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx) = lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi #pop-options (** Map interface *) #push-options "--max_fuel 1 --max_ifuel 2" noeq type map' (a:eqtype) b = | Map : is_le:(a -> a -> bool) -> t:tree a b -> default_v:b -> invs:squash (is_cmp is_le /\ inv is_le t None None) -> map' a b #pop-options let map = map' let const a b is_le d = Map is_le Empty d ()
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sel (#a:eqtype) (#b:Type) (m:map a b) (key:a) : b
[]
Vale.Lib.MapTree.sel
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.MapTree.map a b -> key: a -> b
{ "end_col": 52, "end_line": 150, "start_col": 2, "start_line": 150 }
FStar.Pervasives.Lemma
val lemma_sel_upd_self (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : Lemma (ensures sel (upd m key value) key == value) [SMTPat (sel (upd m key value) key)]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_sel_upd_self #a #b (Map is_le t _ _) key value = lemma_get_put_self is_le t key value None None
val lemma_sel_upd_self (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : Lemma (ensures sel (upd m key value) key == value) [SMTPat (sel (upd m key value) key)] let lemma_sel_upd_self #a #b (Map is_le t _ _) key value =
false
null
true
lemma_get_put_self is_le t key value None None
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Vale.Lib.MapTree.map", "Prims.bool", "Vale.Lib.MapTree.tree", "Prims.squash", "Prims.l_and", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.inv", "FStar.Pervasives.Native.None", "Vale.Lib.MapTree.lemma_get_put_self", "Prims.unit" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx) = lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi #pop-options (** Map interface *) #push-options "--max_fuel 1 --max_ifuel 2" noeq type map' (a:eqtype) b = | Map : is_le:(a -> a -> bool) -> t:tree a b -> default_v:b -> invs:squash (is_cmp is_le /\ inv is_le t None None) -> map' a b #pop-options let map = map' let const a b is_le d = Map is_le Empty d () let sel #a #b (Map is_le t d _) key = match get is_le t key with Some v -> v | None -> d let upd #a #b (Map is_le t d _) key value = let t' = put is_le t key value in lemma_put_inv is_le t key value None None; Map is_le t' d () let lemma_const a b is_le d key = ()
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_sel_upd_self (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : Lemma (ensures sel (upd m key value) key == value) [SMTPat (sel (upd m key value) key)]
[]
Vale.Lib.MapTree.lemma_sel_upd_self
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.MapTree.map a b -> key: a -> value: b -> FStar.Pervasives.Lemma (ensures Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) key == value) [SMTPat (Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) key)]
{ "end_col": 48, "end_line": 161, "start_col": 2, "start_line": 161 }
FStar.Pervasives.Lemma
val lemma_sel_upd_other (#a:eqtype) (#b:Type) (m:map a b) (key kx:a) (value:b) : Lemma (requires key =!= kx) (ensures sel (upd m key value) kx == sel m kx) [SMTPat (sel (upd m key value) kx)]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_sel_upd_other #a #b (Map is_le t _ _) key kx value = lemma_get_put_other is_le t key kx value None None
val lemma_sel_upd_other (#a:eqtype) (#b:Type) (m:map a b) (key kx:a) (value:b) : Lemma (requires key =!= kx) (ensures sel (upd m key value) kx == sel m kx) [SMTPat (sel (upd m key value) kx)] let lemma_sel_upd_other #a #b (Map is_le t _ _) key kx value =
false
null
true
lemma_get_put_other is_le t key kx value None None
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Vale.Lib.MapTree.map", "Prims.bool", "Vale.Lib.MapTree.tree", "Prims.squash", "Prims.l_and", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.inv", "FStar.Pervasives.Native.None", "Vale.Lib.MapTree.lemma_get_put_other", "Prims.unit" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx) = lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi #pop-options (** Map interface *) #push-options "--max_fuel 1 --max_ifuel 2" noeq type map' (a:eqtype) b = | Map : is_le:(a -> a -> bool) -> t:tree a b -> default_v:b -> invs:squash (is_cmp is_le /\ inv is_le t None None) -> map' a b #pop-options let map = map' let const a b is_le d = Map is_le Empty d () let sel #a #b (Map is_le t d _) key = match get is_le t key with Some v -> v | None -> d let upd #a #b (Map is_le t d _) key value = let t' = put is_le t key value in lemma_put_inv is_le t key value None None; Map is_le t' d () let lemma_const a b is_le d key = () let lemma_sel_upd_self #a #b (Map is_le t _ _) key value = lemma_get_put_self is_le t key value None None
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_sel_upd_other (#a:eqtype) (#b:Type) (m:map a b) (key kx:a) (value:b) : Lemma (requires key =!= kx) (ensures sel (upd m key value) kx == sel m kx) [SMTPat (sel (upd m key value) kx)]
[]
Vale.Lib.MapTree.lemma_sel_upd_other
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.MapTree.map a b -> key: a -> kx: a -> value: b -> FStar.Pervasives.Lemma (requires ~(key == kx)) (ensures Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) kx == Vale.Lib.MapTree.sel m kx) [SMTPat (Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) kx)]
{ "end_col": 52, "end_line": 164, "start_col": 2, "start_line": 164 }
Prims.Tot
val const (a:eqtype) (b:Type) (is_le:(a -> a -> bool){is_cmp is_le}) (default_v:b) : map a b
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let const a b is_le d = Map is_le Empty d ()
val const (a:eqtype) (b:Type) (is_le:(a -> a -> bool){is_cmp is_le}) (default_v:b) : map a b let const a b is_le d =
false
null
false
Map is_le Empty d ()
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.bool", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.Map", "Vale.Lib.MapTree.Empty", "Vale.Lib.MapTree.map" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx) = lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi #pop-options (** Map interface *) #push-options "--max_fuel 1 --max_ifuel 2" noeq type map' (a:eqtype) b = | Map : is_le:(a -> a -> bool) -> t:tree a b -> default_v:b -> invs:squash (is_cmp is_le /\ inv is_le t None None) -> map' a b #pop-options let map = map'
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val const (a:eqtype) (b:Type) (is_le:(a -> a -> bool){is_cmp is_le}) (default_v:b) : map a b
[]
Vale.Lib.MapTree.const
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.eqtype -> b: Type -> is_le: (_: a -> _: a -> Prims.bool){Vale.Lib.MapTree.is_cmp is_le} -> default_v: b -> Vale.Lib.MapTree.map a b
{ "end_col": 22, "end_line": 147, "start_col": 2, "start_line": 147 }
Prims.Tot
val get (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) : option b
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key
val get (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) : option b let rec get (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) : option b =
false
null
false
match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.bool", "Vale.Lib.MapTree.tree", "FStar.Pervasives.Native.None", "Prims.nat", "Prims.op_Equality", "FStar.Pervasives.Native.Some", "Vale.Lib.MapTree.get", "FStar.Pervasives.Native.option" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) : option b
[ "recursion" ]
Vale.Lib.MapTree.get
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> key: a -> FStar.Pervasives.Native.option b
{ "end_col": 21, "end_line": 49, "start_col": 2, "start_line": 42 }
Prims.Tot
val upd (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : map a b
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd #a #b (Map is_le t d _) key value = let t' = put is_le t key value in lemma_put_inv is_le t key value None None; Map is_le t' d ()
val upd (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : map a b let upd #a #b (Map is_le t d _) key value =
false
null
false
let t' = put is_le t key value in lemma_put_inv is_le t key value None None; Map is_le t' d ()
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Vale.Lib.MapTree.map", "Prims.bool", "Vale.Lib.MapTree.tree", "Prims.squash", "Prims.l_and", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.inv", "FStar.Pervasives.Native.None", "Vale.Lib.MapTree.Map", "Prims.unit", "Vale.Lib.MapTree.lemma_put_inv", "Vale.Lib.MapTree.put" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx) = lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi #pop-options (** Map interface *) #push-options "--max_fuel 1 --max_ifuel 2" noeq type map' (a:eqtype) b = | Map : is_le:(a -> a -> bool) -> t:tree a b -> default_v:b -> invs:squash (is_cmp is_le /\ inv is_le t None None) -> map' a b #pop-options let map = map' let const a b is_le d = Map is_le Empty d () let sel #a #b (Map is_le t d _) key = match get is_le t key with Some v -> v | None -> d
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val upd (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : map a b
[]
Vale.Lib.MapTree.upd
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.MapTree.map a b -> key: a -> value: b -> Vale.Lib.MapTree.map a b
{ "end_col": 19, "end_line": 155, "start_col": 43, "start_line": 152 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
let rec inv (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (lo hi: option a) =
false
null
false
let op_Less x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.bool", "Vale.Lib.MapTree.tree", "FStar.Pervasives.Native.option", "Prims.l_True", "Prims.nat", "Prims.l_and", "Prims.b2t", "Vale.Lib.MapTree.inv", "FStar.Pervasives.Native.Some", "Prims.logical", "Vale.Lib.MapTree.is_lt_option" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inv : is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> lo: FStar.Pervasives.Native.option a -> hi: FStar.Pervasives.Native.option a -> Prims.logical
[ "recursion" ]
Vale.Lib.MapTree.inv
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> lo: FStar.Pervasives.Native.option a -> hi: FStar.Pervasives.Native.option a -> Prims.logical
{ "end_col": 60, "end_line": 74, "start_col": 88, "start_line": 68 }
Prims.Tot
val put (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) : tree a b
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value))
val put (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) : tree a b let rec put (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) : tree a b =
false
null
false
match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value))
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.bool", "Vale.Lib.MapTree.tree", "Vale.Lib.MapTree.mkNode", "Vale.Lib.MapTree.Empty", "Prims.nat", "Prims.op_Equality", "Vale.Lib.MapTree.balance", "Vale.Lib.MapTree.put" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val put (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) : tree a b
[ "recursion" ]
Vale.Lib.MapTree.put
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> key: a -> value: b -> Vale.Lib.MapTree.tree a b
{ "end_col": 52, "end_line": 59, "start_col": 2, "start_line": 52 }
FStar.Pervasives.Lemma
val lemma_get_put_self (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi
val lemma_get_put_self (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) let rec lemma_get_put_self (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) =
false
null
true
match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.bool", "Vale.Lib.MapTree.tree", "FStar.Pervasives.Native.option", "Prims.nat", "Prims.op_Equality", "Vale.Lib.MapTree.lemma_get_put_self", "FStar.Pervasives.Native.Some", "Prims.unit", "Prims.l_and", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.inv", "Prims.squash", "Prims.eq2", "Vale.Lib.MapTree.get", "Vale.Lib.MapTree.put", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value)
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_get_put_self (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value)
[ "recursion" ]
Vale.Lib.MapTree.lemma_get_put_self
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> key: a -> value: b -> lo: FStar.Pervasives.Native.option a -> hi: FStar.Pervasives.Native.option a -> FStar.Pervasives.Lemma (requires Vale.Lib.MapTree.is_cmp is_le /\ Vale.Lib.MapTree.inv is_le t lo hi) (ensures Vale.Lib.MapTree.get is_le (Vale.Lib.MapTree.put is_le t key value) key == FStar.Pervasives.Native.Some value)
{ "end_col": 54, "end_line": 107, "start_col": 2, "start_line": 100 }
FStar.Pervasives.Lemma
val lemma_put_inv (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi) (ensures inv is_le (put is_le t key value) lo hi)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi
val lemma_put_inv (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi) (ensures inv is_le (put is_le t key value) lo hi) let rec lemma_put_inv (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi) (ensures inv is_le (put is_le t key value) lo hi) =
false
null
true
match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.bool", "Vale.Lib.MapTree.tree", "FStar.Pervasives.Native.option", "Prims.nat", "Prims.op_Equality", "Vale.Lib.MapTree.lemma_put_inv", "FStar.Pervasives.Native.Some", "Prims.unit", "Prims.l_and", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.inv", "Prims.b2t", "Vale.Lib.MapTree.is_lt_option", "Prims.squash", "Vale.Lib.MapTree.put", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi)
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_put_inv (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi) (ensures inv is_le (put is_le t key value) lo hi)
[ "recursion" ]
Vale.Lib.MapTree.lemma_put_inv
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> key: a -> value: b -> lo: FStar.Pervasives.Native.option a -> hi: FStar.Pervasives.Native.option a -> FStar.Pervasives.Lemma (requires Vale.Lib.MapTree.is_cmp is_le /\ Vale.Lib.MapTree.inv is_le t lo hi /\ Vale.Lib.MapTree.is_lt_option is_le lo (FStar.Pervasives.Native.Some key) /\ Vale.Lib.MapTree.is_lt_option is_le (FStar.Pervasives.Native.Some key) hi) (ensures Vale.Lib.MapTree.inv is_le (Vale.Lib.MapTree.put is_le t key value) lo hi)
{ "end_col": 49, "end_line": 94, "start_col": 2, "start_line": 87 }
FStar.Pervasives.Lemma
val lemma_get_put_other (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key kx: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx) (ensures get is_le (put is_le t key value) kx == get is_le t kx)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx) = lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi
val lemma_get_put_other (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key kx: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx) (ensures get is_le (put is_le t key value) kx == get is_le t kx) let rec lemma_get_put_other (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key kx: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx) (ensures get is_le (put is_le t key value) kx == get is_le t kx) =
false
null
true
lemma_put_inv is_le t key value lo hi; match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_other is_le l key kx value lo (Some k) else lemma_get_put_other is_le r key kx value (Some k) hi
{ "checked_file": "Vale.Lib.MapTree.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Lib.MapTree.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.bool", "Vale.Lib.MapTree.tree", "FStar.Pervasives.Native.option", "Prims.nat", "Prims.op_Equality", "Vale.Lib.MapTree.lemma_get_put_other", "FStar.Pervasives.Native.Some", "Prims.unit", "Vale.Lib.MapTree.lemma_put_inv", "Prims.l_and", "Vale.Lib.MapTree.is_cmp", "Vale.Lib.MapTree.inv", "Prims.b2t", "Vale.Lib.MapTree.is_lt_option", "Prims.l_not", "Prims.eq2", "Prims.squash", "Vale.Lib.MapTree.get", "Vale.Lib.MapTree.put", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Lib.MapTree open FStar.Mul (** Balanced tree implementation *) type tree (a:eqtype) (b:Type) = | Empty : tree a b | Node : a -> b -> nat -> tree a b -> tree a b -> tree a b let height (#a:eqtype) (#b:Type) (t:tree a b) : nat = match t with | Empty -> 0 | Node _ _ h _ _ -> h let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b = let hl = height l in let hr = height r in let h = if hl > hr then hl else hr in Node key value (h + 1) l r let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr | _ -> t let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r) | _ -> t let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b = match t with | Node _ _ _ l r -> let hl = height l in let hr = height r in if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t | _ -> t let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b = match t with | Empty -> None | Node k v h l r -> if key = k then Some v else if is_le key k then get is_le l key else get is_le r key let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b = match t with | Empty -> mkNode key value Empty Empty | Node k v _ l r -> if key = k then mkNode k value l r else if is_le key k then balance (mkNode k v (put is_le l key value) r) else balance (mkNode k v l (put is_le r key value)) (** Invariants and proofs of get-put correctness *) let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool = match (x, y) with | (Some x, Some y) -> is_le x y && x <> y | _ -> true let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) = let (<) x y = is_lt_option is_le x y in match t with | Empty -> True | Node x _ _ l r -> let x = Some x in lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi #push-options "--max_fuel 2 --max_ifuel 1" let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi ) (ensures inv is_le (put is_le t key value) lo hi) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_put_inv is_le l key value lo (Some k) else lemma_put_inv is_le r key value (Some k) hi let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi) (ensures get is_le (put is_le t key value) key == Some value) = match t with | Empty -> () | Node k v _ l r -> if key = k then () else if is_le key k then lemma_get_put_self is_le l key value lo (Some k) else lemma_get_put_self is_le r key value (Some k) hi let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx ) (ensures get is_le (put is_le t key value) kx == get is_le t kx)
false
false
Vale.Lib.MapTree.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_get_put_other (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key kx: a) (value: b) (lo hi: option a) : Lemma (requires is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\ is_lt_option is_le (Some key) hi /\ key =!= kx) (ensures get is_le (put is_le t key value) kx == get is_le t kx)
[ "recursion" ]
Vale.Lib.MapTree.lemma_get_put_other
{ "file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> key: a -> kx: a -> value: b -> lo: FStar.Pervasives.Native.option a -> hi: FStar.Pervasives.Native.option a -> FStar.Pervasives.Lemma (requires Vale.Lib.MapTree.is_cmp is_le /\ Vale.Lib.MapTree.inv is_le t lo hi /\ Vale.Lib.MapTree.is_lt_option is_le lo (FStar.Pervasives.Native.Some key) /\ Vale.Lib.MapTree.is_lt_option is_le (FStar.Pervasives.Native.Some key) hi /\ ~(key == kx)) (ensures Vale.Lib.MapTree.get is_le (Vale.Lib.MapTree.put is_le t key value) kx == Vale.Lib.MapTree.get is_le t kx)
{ "end_col": 58, "end_line": 128, "start_col": 2, "start_line": 120 }
Prims.Tot
val pow2_63:nat
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pow2_63:nat = 0x8000000000000000
val pow2_63:nat let pow2_63:nat =
false
null
false
0x8000000000000000
{ "checked_file": "Vale.Curve25519.FastHybrid_helpers.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.Fast_defs.fst.checked", "prims.fst.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Vale.Curve25519.FastHybrid_helpers.fsti" }
[ "total" ]
[]
[]
module Vale.Curve25519.FastHybrid_helpers open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Mul open FStar.Tactics open FStar.Tactics.CanonCommSemiring open Vale.Curve25519.Fast_defs open FStar.Calc let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () //; dump "Final"
false
true
Vale.Curve25519.FastHybrid_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow2_63:nat
[]
Vale.Curve25519.FastHybrid_helpers.pow2_63
{ "file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastHybrid_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.nat
{ "end_col": 43, "end_line": 13, "start_col": 25, "start_line": 13 }
FStar.Tactics.Effect.Tac
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring ()
let int_canon =
true
null
false
fun _ -> norm [delta; zeta; iota]; int_semiring ()
{ "checked_file": "Vale.Curve25519.FastHybrid_helpers.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.Fast_defs.fst.checked", "prims.fst.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Vale.Curve25519.FastHybrid_helpers.fsti" }
[]
[ "FStar.Tactics.CanonCommSemiring.int_semiring", "Prims.unit", "FStar.Tactics.V1.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "Prims.Nil" ]
[]
module Vale.Curve25519.FastHybrid_helpers open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Mul open FStar.Tactics open FStar.Tactics.CanonCommSemiring open Vale.Curve25519.Fast_defs open FStar.Calc
false
false
Vale.Curve25519.FastHybrid_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val int_canon : _: _ -> FStar.Tactics.Effect.Tac Prims.unit
[]
Vale.Curve25519.FastHybrid_helpers.int_canon
{ "file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastHybrid_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: _ -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 66, "end_line": 11, "start_col": 16, "start_line": 11 }
FStar.Pervasives.Lemma
val lemma_mul_pow256_add (x y: nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime)
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_mul_pow256_add (x y:nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime) = assert_norm (pow2_256 % prime == 38); ()
val lemma_mul_pow256_add (x y: nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime) let lemma_mul_pow256_add (x y: nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime) =
false
null
true
assert_norm (pow2_256 % prime == 38); ()
{ "checked_file": "Vale.Curve25519.FastHybrid_helpers.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.Fast_defs.fst.checked", "prims.fst.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Vale.Curve25519.FastHybrid_helpers.fsti" }
[ "lemma" ]
[ "Prims.nat", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Vale.Curve25519.Fast_defs.pow2_256", "Vale.Curve25519.Fast_defs.prime", "Prims.l_True", "Prims.squash", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Curve25519.FastHybrid_helpers open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Mul open FStar.Tactics open FStar.Tactics.CanonCommSemiring open Vale.Curve25519.Fast_defs open FStar.Calc let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () //; dump "Final" unfold let pow2_63:nat = 0x8000000000000000 let _ = assert_norm (pow2_63 == pow2 63) let lemma_mul_pow256_add (x y:nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime)
false
false
Vale.Curve25519.FastHybrid_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_mul_pow256_add (x y: nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime)
[]
Vale.Curve25519.FastHybrid_helpers.lemma_mul_pow256_add
{ "file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastHybrid_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.nat -> y: Prims.nat -> FStar.Pervasives.Lemma (ensures (x + y * Vale.Curve25519.Fast_defs.pow2_256) % Vale.Curve25519.Fast_defs.prime == (x + y * 38) % Vale.Curve25519.Fast_defs.prime)
{ "end_col": 4, "end_line": 21, "start_col": 2, "start_line": 20 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y)
let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) =
false
null
false
(forall x. g (f x) == x) /\ (forall y. f (g y) == y)
{ "checked_file": "LowStar.BufferView.Down.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.Down.fsti" }
[ "total" ]
[ "Prims.l_and", "Prims.l_Forall", "Prims.eq2", "Prims.logical" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.BufferView.Down (** * A "down view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.Down.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a down view requires providing a pair of mutually inverse functions * from `a` to sequences of `b`. (e.g., from a `lbuffer u32 n` to a `lbuffer u8 (4*n)`) * * I.e., a down view allows "exploding" an `a` into its component `b`'s. * In contrast, an "up view" (see LowStar.BufferView.Up) allows * "compacting" a sequences of `a`'s into a `b`. * (e.g., from an `lbuffer u8 (4*n)` to an `lbuffer u32 n`) **) open LowStar.Monotonic.Buffer open FStar.Mul module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b))
false
false
LowStar.BufferView.Down.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inverses : f: (_: a -> Prims.GTot b) -> g: (_: b -> Prims.GTot a) -> Prims.logical
[]
LowStar.BufferView.Down.inverses
{ "file_name": "ulib/LowStar.BufferView.Down.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> Prims.GTot b) -> g: (_: b -> Prims.GTot a) -> Prims.logical
{ "end_col": 26, "end_line": 48, "start_col": 2, "start_line": 47 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Math.Lemmas", "short_module": "Math" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_buffer_t (#dest:Type) (b:buffer dest) = B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b)
let as_buffer_t (#dest: Type) (b: buffer dest) =
false
null
false
B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b)
{ "checked_file": "LowStar.BufferView.Down.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.Down.fsti" }
[ "total" ]
[ "LowStar.BufferView.Down.buffer", "LowStar.Monotonic.Buffer.mbuffer", "FStar.Pervasives.__proj__Mkdtuple4__item___1", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.Down.buffer_view", "FStar.Pervasives.__proj__Mkdtuple4__item___2", "FStar.Pervasives.__proj__Mkdtuple4__item___3" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.BufferView.Down (** * A "down view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.Down.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a down view requires providing a pair of mutually inverse functions * from `a` to sequences of `b`. (e.g., from a `lbuffer u32 n` to a `lbuffer u8 (4*n)`) * * I.e., a down view allows "exploding" an `a` into its component `b`'s. * In contrast, an "up view" (see LowStar.BufferView.Up) allows * "compacting" a sequences of `a`'s into a `b`. * (e.g., from an `lbuffer u8 (4*n)` to an `lbuffer u32 n`) **) open LowStar.Monotonic.Buffer open FStar.Mul module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps single `a`'s to an `n`-lengthed sequence of `b`s noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(a -> GTot (Seq.lseq b n)) -> put:(Seq.lseq b n -> GTot a) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. /// val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type lives in a higher universe, /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe) let buffer (dest:Type u#a) : Type u#(max 1 a) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest)
false
false
LowStar.BufferView.Down.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_buffer_t : b: LowStar.BufferView.Down.buffer dest -> Type0
[]
LowStar.BufferView.Down.as_buffer_t
{ "file_name": "ulib/LowStar.BufferView.Down.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: LowStar.BufferView.Down.buffer dest -> Type0
{ "end_col": 110, "end_line": 88, "start_col": 47, "start_line": 88 }
Prims.Tot
val buffer (dest: Type u#a) : Type u#(max 1 a)
[ { "abbrev": true, "full_module": "FStar.Math.Lemmas", "short_module": "Math" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let buffer (dest:Type u#a) : Type u#(max 1 a) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest)
val buffer (dest: Type u#a) : Type u#(max 1 a) let buffer (dest: Type u#a) : Type u#(max 1 a) =
false
null
false
(src: Type0 & rrel: B.srel src & rel: B.srel src & buffer_view src rrel rel dest)
{ "checked_file": "LowStar.BufferView.Down.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.Down.fsti" }
[ "total" ]
[ "FStar.Pervasives.dtuple4", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.Down.buffer_view" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.BufferView.Down (** * A "down view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.Down.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a down view requires providing a pair of mutually inverse functions * from `a` to sequences of `b`. (e.g., from a `lbuffer u32 n` to a `lbuffer u8 (4*n)`) * * I.e., a down view allows "exploding" an `a` into its component `b`'s. * In contrast, an "up view" (see LowStar.BufferView.Up) allows * "compacting" a sequences of `a`'s into a `b`. * (e.g., from an `lbuffer u8 (4*n)` to an `lbuffer u32 n`) **) open LowStar.Monotonic.Buffer open FStar.Mul module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps single `a`'s to an `n`-lengthed sequence of `b`s noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(a -> GTot (Seq.lseq b n)) -> put:(Seq.lseq b n -> GTot a) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. /// val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type lives in a higher universe, /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe)
false
true
LowStar.BufferView.Down.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val buffer (dest: Type u#a) : Type u#(max 1 a)
[]
LowStar.BufferView.Down.buffer
{ "file_name": "ulib/LowStar.BufferView.Down.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
dest: Type -> Type
{ "end_col": 126, "end_line": 86, "start_col": 48, "start_line": 86 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Math.Lemmas", "short_module": "Math" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let live #b h (vb:buffer b) = live h (as_buffer vb)
let live #b h (vb: buffer b) =
false
null
false
live h (as_buffer vb)
{ "checked_file": "LowStar.BufferView.Down.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.Down.fsti" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.BufferView.Down.buffer", "LowStar.Monotonic.Buffer.live", "FStar.Pervasives.__proj__Mkdtuple4__item___1", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.Down.buffer_view", "FStar.Pervasives.__proj__Mkdtuple4__item___2", "FStar.Pervasives.__proj__Mkdtuple4__item___3", "LowStar.BufferView.Down.as_buffer" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.BufferView.Down (** * A "down view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.Down.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a down view requires providing a pair of mutually inverse functions * from `a` to sequences of `b`. (e.g., from a `lbuffer u32 n` to a `lbuffer u8 (4*n)`) * * I.e., a down view allows "exploding" an `a` into its component `b`'s. * In contrast, an "up view" (see LowStar.BufferView.Up) allows * "compacting" a sequences of `a`'s into a `b`. * (e.g., from an `lbuffer u8 (4*n)` to an `lbuffer u32 n`) **) open LowStar.Monotonic.Buffer open FStar.Mul module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps single `a`'s to an `n`-lengthed sequence of `b`s noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(a -> GTot (Seq.lseq b n)) -> put:(Seq.lseq b n -> GTot a) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. /// val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type lives in a higher universe, /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe) let buffer (dest:Type u#a) : Type u#(max 1 a) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest) let as_buffer_t (#dest:Type) (b:buffer dest) = B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b) /// `mk_buffer_view`: The main constructor val mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest) : GTot (buffer dest) /// `as_buffer`: Projecting the underlying B.buffer from its view val as_buffer (#b:Type) (v:buffer b) : as_buffer_t v /// A lemma-relating projector to constructor val as_buffer_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ Mkdtuple4?._2 bv == rrel /\ Mkdtuple4?._3 bv == rel /\ as_buffer bv == b) [SMTPat (as_buffer (mk_buffer_view b v))] /// `get_view`: Projecting the view functions itself val get_view (#b : Type) (v:buffer b) : view (Mkdtuple4?._1 v) b /// A lemma-relating projector to constructor val get_view_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ get_view bv == v) [SMTPat (get_view (mk_buffer_view b v))] /// `live h vb`: liveness of a buffer view corresponds to liveness of /// the underlying buffer
false
false
LowStar.BufferView.Down.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val live : h: FStar.Monotonic.HyperStack.mem -> vb: LowStar.BufferView.Down.buffer b -> Type0
[]
LowStar.BufferView.Down.live
{ "file_name": "ulib/LowStar.BufferView.Down.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h: FStar.Monotonic.HyperStack.mem -> vb: LowStar.BufferView.Down.buffer b -> Type0
{ "end_col": 51, "end_line": 126, "start_col": 30, "start_line": 126 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Math.Lemmas", "short_module": "Math" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modifies (#b: _) (vb:buffer b) (h h':HS.mem) = B.modifies (B.loc_buffer (as_buffer vb)) h h'
let modifies (#b: _) (vb: buffer b) (h h': HS.mem) =
false
null
false
B.modifies (B.loc_buffer (as_buffer vb)) h h'
{ "checked_file": "LowStar.BufferView.Down.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.Down.fsti" }
[ "total" ]
[ "LowStar.BufferView.Down.buffer", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Pervasives.__proj__Mkdtuple4__item___1", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.Down.buffer_view", "FStar.Pervasives.__proj__Mkdtuple4__item___2", "FStar.Pervasives.__proj__Mkdtuple4__item___3", "LowStar.BufferView.Down.as_buffer" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.BufferView.Down (** * A "down view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.Down.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a down view requires providing a pair of mutually inverse functions * from `a` to sequences of `b`. (e.g., from a `lbuffer u32 n` to a `lbuffer u8 (4*n)`) * * I.e., a down view allows "exploding" an `a` into its component `b`'s. * In contrast, an "up view" (see LowStar.BufferView.Up) allows * "compacting" a sequences of `a`'s into a `b`. * (e.g., from an `lbuffer u8 (4*n)` to an `lbuffer u32 n`) **) open LowStar.Monotonic.Buffer open FStar.Mul module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps single `a`'s to an `n`-lengthed sequence of `b`s noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(a -> GTot (Seq.lseq b n)) -> put:(Seq.lseq b n -> GTot a) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. /// val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type lives in a higher universe, /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe) let buffer (dest:Type u#a) : Type u#(max 1 a) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest) let as_buffer_t (#dest:Type) (b:buffer dest) = B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b) /// `mk_buffer_view`: The main constructor val mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest) : GTot (buffer dest) /// `as_buffer`: Projecting the underlying B.buffer from its view val as_buffer (#b:Type) (v:buffer b) : as_buffer_t v /// A lemma-relating projector to constructor val as_buffer_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ Mkdtuple4?._2 bv == rrel /\ Mkdtuple4?._3 bv == rel /\ as_buffer bv == b) [SMTPat (as_buffer (mk_buffer_view b v))] /// `get_view`: Projecting the view functions itself val get_view (#b : Type) (v:buffer b) : view (Mkdtuple4?._1 v) b /// A lemma-relating projector to constructor val get_view_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ get_view bv == v) [SMTPat (get_view (mk_buffer_view b v))] /// `live h vb`: liveness of a buffer view corresponds to liveness of /// the underlying buffer unfold let live #b h (vb:buffer b) = live h (as_buffer vb) /// `length vb`: is defined in terms of the underlying buffer /// /// Internally, it is defined as /// /// ``` /// length (as_buffer vb) * View?.n (get_view vb) /// ``` /// /// However, rather than expose this definition to callers, we treat /// length abstractly. /// /// To reveal its definition explicitly, use the `length_eq` lemma below. val length (#b: _) (vb:buffer b) : GTot nat /// `length_eq`: Reveals the definition of the `length` function val length_eq (#b: _) (vb:buffer b) : Lemma (length vb = B.length (as_buffer vb) * View?.n (get_view vb)) /// `indexing` val indexing (#b: _) (vb:buffer b) (i:nat{i < length vb}) : Lemma (let n = View?.n (get_view vb) in let vlen = length vb in n * (i / n) < vlen /\ n * (i / n) + n <= vlen) /// `sel h vb i` : selects element at index `i` from the buffer `vb` in heap `h` val sel (#b: _) (h:HS.mem) (vb:buffer b) (i:nat{i < length vb}) : GTot b /// `upd h vb i x`: stores `x` at index `i` in the buffer `vb` in heap `h` val upd (#b: _) (h:HS.mem) (vb:buffer b{live h vb}) (i:nat{i < length vb}) (x:b) : GTot HS.mem /// `sel_upd`: A classic select/update lemma for reasoning about maps val sel_upd (#b:_) (vb:buffer b) (i:nat{i < length vb}) (j:nat{j < length vb}) (x:b) (h:HS.mem{live h vb}) : Lemma (if i = j then sel (upd h vb i x) vb j == x else sel (upd h vb i x) vb j == sel h vb j) [SMTPat (sel (upd h vb i x) vb j)] val lemma_upd_with_sel (#b:_) (vb:buffer b) (i:nat{i < length vb}) (h:HS.mem{live h vb}) :Lemma (upd h vb i (sel h vb i) == h) /// `modifies` on views is just defined in terms of the underlying buffer unfold let modifies (#b: _) (vb:buffer b)
false
false
LowStar.BufferView.Down.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modifies : vb: LowStar.BufferView.Down.buffer b -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Type0
[]
LowStar.BufferView.Down.modifies
{ "file_name": "ulib/LowStar.BufferView.Down.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
vb: LowStar.BufferView.Down.buffer b -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Type0
{ "end_col": 51, "end_line": 193, "start_col": 6, "start_line": 193 }
Prims.Tot
val from_list_be (l: list bool) : int
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let from_list_be (l:list bool) : int = from_list_le (List.rev l)
val from_list_be (l: list bool) : int let from_list_be (l: list bool) : int =
false
null
false
from_list_le (List.rev l)
{ "checked_file": "Vale.Lib.Lists.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Lists.fsti" }
[ "total" ]
[ "Prims.list", "Prims.bool", "Vale.Lib.Lists.from_list_le", "FStar.List.Tot.Base.rev", "Prims.int" ]
[]
module Vale.Lib.Lists open FStar.List.Tot open FStar.Seq open FStar.UInt open FStar.Mul module List = FStar.List.Tot open FStar.List.Tot.Properties val singleton_list_rev (#a:Type) (x:a) : Lemma (List.rev [x] == [x]) val list_cons_is_append (#a:Type) (h:a) (t:list a) : Lemma (h::t == [h] @ t) val singleton_list_seq (#a:Type) (x:a) : Lemma (seq_of_list [x] == create 1 x) val list_append_length (#a:Type) (x y:list a) : Lemma (List.length (x @ y) == List.length x + List.length y) val list_append_index (#a:Type) (x y:list a) (i:nat) : Lemma (requires i < List.length (x @ y)) (ensures ( let nx = List.length x in (i >= nx ==> i - nx < List.length y) /\ List.index (x @ y) i == (if i < nx then List.index x i else List.index y (i - nx)) )) val append_list_seq (#a:Type) (x y:list a) : Lemma (seq_of_list (x @ y) == append (seq_of_list x) (seq_of_list y)) let rec from_list_le (l:list bool) : int = match l with | [] -> 0 | h::t -> (if h then 1 else 0) + 2 * (from_list_le t)
false
true
Vale.Lib.Lists.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val from_list_be (l: list bool) : int
[]
Vale.Lib.Lists.from_list_be
{ "file_name": "vale/code/lib/collections/Vale.Lib.Lists.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Prims.list Prims.bool -> Prims.int
{ "end_col": 27, "end_line": 39, "start_col": 2, "start_line": 39 }
Prims.Tot
val from_list_le (l: list bool) : int
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec from_list_le (l:list bool) : int = match l with | [] -> 0 | h::t -> (if h then 1 else 0) + 2 * (from_list_le t)
val from_list_le (l: list bool) : int let rec from_list_le (l: list bool) : int =
false
null
false
match l with | [] -> 0 | h :: t -> (if h then 1 else 0) + 2 * (from_list_le t)
{ "checked_file": "Vale.Lib.Lists.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Lists.fsti" }
[ "total" ]
[ "Prims.list", "Prims.bool", "Prims.op_Addition", "Prims.int", "FStar.Mul.op_Star", "Vale.Lib.Lists.from_list_le" ]
[]
module Vale.Lib.Lists open FStar.List.Tot open FStar.Seq open FStar.UInt open FStar.Mul module List = FStar.List.Tot open FStar.List.Tot.Properties val singleton_list_rev (#a:Type) (x:a) : Lemma (List.rev [x] == [x]) val list_cons_is_append (#a:Type) (h:a) (t:list a) : Lemma (h::t == [h] @ t) val singleton_list_seq (#a:Type) (x:a) : Lemma (seq_of_list [x] == create 1 x) val list_append_length (#a:Type) (x y:list a) : Lemma (List.length (x @ y) == List.length x + List.length y) val list_append_index (#a:Type) (x y:list a) (i:nat) : Lemma (requires i < List.length (x @ y)) (ensures ( let nx = List.length x in (i >= nx ==> i - nx < List.length y) /\ List.index (x @ y) i == (if i < nx then List.index x i else List.index y (i - nx)) )) val append_list_seq (#a:Type) (x y:list a) : Lemma (seq_of_list (x @ y) == append (seq_of_list x) (seq_of_list y))
false
true
Vale.Lib.Lists.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val from_list_le (l: list bool) : int
[ "recursion" ]
Vale.Lib.Lists.from_list_le
{ "file_name": "vale/code/lib/collections/Vale.Lib.Lists.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Prims.list Prims.bool -> Prims.int
{ "end_col": 55, "end_line": 36, "start_col": 2, "start_line": 34 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p)
let aff_point_inv (h: mem) (p: aff_point) =
false
null
false
aff_point_inv_seq (as_seq h p)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.aff_point", "Hacl.Impl.P256.Point.aff_point_inv_seq", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.logical" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point_inv : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.logical
[]
Hacl.Impl.P256.Point.aff_point_inv
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.logical
{ "end_col": 32, "end_line": 46, "start_col": 2, "start_line": 46 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime
let aff_point_inv_seq (p: aff_point_seq) =
false
null
false
let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Hacl.Impl.P256.Point.aff_point_seq", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Spec.P256.PointOps.prime", "Prims.logical", "FStar.Pervasives.Native.tuple2", "Hacl.Impl.P256.Point.as_aff_point_nat_seq" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4)
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point_inv_seq : p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.logical
[]
Hacl.Impl.P256.Point.aff_point_inv_seq
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.logical
{ "end_col": 28, "end_line": 34, "start_col": 41, "start_line": 32 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point = lbuffer uint64 8ul
let aff_point =
false
null
false
lbuffer uint64 8ul
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point : Type0
[]
Hacl.Impl.P256.Point.aff_point
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 38, "start_col": 16, "start_line": 38 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_inv (h:mem) (p:point) = point_inv_seq (as_seq h p)
let point_inv (h: mem) (p: point) =
false
null
false
point_inv_seq (as_seq h p)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Point.point_inv_seq", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.logical" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p) noextract
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_inv : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.logical
[]
Hacl.Impl.P256.Point.point_inv
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.logical
{ "end_col": 28, "end_line": 93, "start_col": 2, "start_line": 93 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime
let point_inv_seq (p: point_seq) =
false
null
false
let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Hacl.Impl.P256.Point.point_seq", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Spec.P256.PointOps.prime", "Prims.logical", "FStar.Pervasives.Native.tuple3", "Hacl.Impl.P256.Point.as_point_nat_seq" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4)
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_inv_seq : p: Hacl.Impl.P256.Point.point_seq -> Prims.logical
[]
Hacl.Impl.P256.Point.point_inv_seq
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.point_seq -> Prims.logical
{ "end_col": 43, "end_line": 81, "start_col": 33, "start_line": 79 }
Prims.GTot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p)
let as_aff_point_nat (h: mem) (p: aff_point) =
false
null
false
as_aff_point_nat_seq (as_seq h p)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.aff_point", "Hacl.Impl.P256.Point.as_aff_point_nat_seq", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.tuple2", "Prims.nat" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_aff_point_nat : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.GTot (Prims.nat * Prims.nat)
[]
Hacl.Impl.P256.Point.as_aff_point_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.GTot (Prims.nat * Prims.nat)
{ "end_col": 35, "end_line": 42, "start_col": 2, "start_line": 42 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point = lbuffer uint64 12ul
let point =
false
null
false
lbuffer uint64 12ul
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point : Type0
[]
Hacl.Impl.P256.Point.point
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 31, "end_line": 85, "start_col": 12, "start_line": 85 }
Prims.GTot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p)
let as_point_nat (h: mem) (p: point) =
false
null
false
as_point_nat_seq (as_seq h p)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Point.as_point_nat_seq", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.tuple3", "Prims.nat" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_point_nat : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.GTot ((Prims.nat * Prims.nat) * Prims.nat)
[]
Hacl.Impl.P256.Point.as_point_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.GTot ((Prims.nat * Prims.nat) * Prims.nat)
{ "end_col": 31, "end_line": 89, "start_col": 2, "start_line": 89 }
Prims.Tot
val from_mont_point (a: tuple3 nat nat nat) : S.proj_point
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
val from_mont_point (a: tuple3 nat nat nat) : S.proj_point let from_mont_point (a: tuple3 nat nat nat) : S.proj_point =
false
null
false
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple3", "Prims.nat", "FStar.Pervasives.Native.Mktuple3", "Hacl.Spec.P256.Montgomery.from_mont", "Spec.P256.PointOps.proj_point" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val from_mont_point (a: tuple3 nat nat nat) : S.proj_point
[]
Hacl.Impl.P256.Point.from_mont_point
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: ((Prims.nat * Prims.nat) * Prims.nat) -> Spec.P256.PointOps.proj_point
{ "end_col": 67, "end_line": 20, "start_col": 59, "start_line": 19 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point_seq = LSeq.lseq uint64 8
let aff_point_seq =
false
null
false
LSeq.lseq uint64 8
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point_seq : Type0
[]
Hacl.Impl.P256.Point.aff_point_seq
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 38, "end_line": 26, "start_col": 20, "start_line": 26 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_seq = LSeq.lseq uint64 12
let point_seq =
false
null
false
LSeq.lseq uint64 12
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_seq : Type0
[]
Hacl.Impl.P256.Point.point_seq
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 35, "end_line": 72, "start_col": 16, "start_line": 72 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4)
let as_aff_point_nat_seq (p: aff_point_seq) =
false
null
false
BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Hacl.Impl.P256.Point.aff_point_seq", "FStar.Pervasives.Native.Mktuple2", "Prims.nat", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.U64", "Lib.Sequence.sub", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_aff_point_nat_seq : p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.nat * Prims.nat
[]
Hacl.Impl.P256.Point.as_aff_point_nat_seq
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.nat * Prims.nat
{ "end_col": 26, "end_line": 30, "start_col": 2, "start_line": 29 }
Prims.GTot
val aff_point_y_as_nat (h: mem) (p: aff_point) : GTot nat
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul)
val aff_point_y_as_nat (h: mem) (p: aff_point) : GTot nat let aff_point_y_as_nat (h: mem) (p: aff_point) : GTot nat =
false
null
false
as_nat h (gsub p 4ul 4ul)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.aff_point", "Hacl.Impl.P256.Bignum.as_nat", "Lib.Buffer.gsub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.nat" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point_y_as_nat (h: mem) (p: aff_point) : GTot nat
[]
Hacl.Impl.P256.Point.aff_point_y_as_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.GTot Prims.nat
{ "end_col": 27, "end_line": 54, "start_col": 2, "start_line": 54 }
Prims.GTot
val point_y_as_nat (h: mem) (e: point) : GTot nat
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_y_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 4ul 4ul)
val point_y_as_nat (h: mem) (e: point) : GTot nat let point_y_as_nat (h: mem) (e: point) : GTot nat =
false
null
false
as_nat h (gsub e 4ul 4ul)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.as_nat", "Lib.Buffer.gsub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.nat" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p) noextract let point_inv (h:mem) (p:point) = point_inv_seq (as_seq h p) noextract let point_x_as_nat (h:mem) (p:point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_y_as_nat (h: mem) (e: point) : GTot nat
[]
Hacl.Impl.P256.Point.point_y_as_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> e: Hacl.Impl.P256.Point.point -> Prims.GTot Prims.nat
{ "end_col": 27, "end_line": 101, "start_col": 2, "start_line": 101 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4)
let as_point_nat_seq (p: point_seq) =
false
null
false
BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "total" ]
[ "Hacl.Impl.P256.Point.point_seq", "FStar.Pervasives.Native.Mktuple3", "Prims.nat", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.U64", "Lib.Sequence.sub", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.tuple3" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12
false
true
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_point_nat_seq : p: Hacl.Impl.P256.Point.point_seq -> (Prims.nat * Prims.nat) * Prims.nat
[]
Hacl.Impl.P256.Point.as_point_nat_seq
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.point_seq -> (Prims.nat * Prims.nat) * Prims.nat
{ "end_col": 26, "end_line": 77, "start_col": 2, "start_line": 75 }
Prims.GTot
val aff_point_x_as_nat (h: mem) (p: aff_point) : GTot nat
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul)
val aff_point_x_as_nat (h: mem) (p: aff_point) : GTot nat let aff_point_x_as_nat (h: mem) (p: aff_point) : GTot nat =
false
null
false
as_nat h (gsub p 0ul 4ul)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.aff_point", "Hacl.Impl.P256.Bignum.as_nat", "Lib.Buffer.gsub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.nat" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point_x_as_nat (h: mem) (p: aff_point) : GTot nat
[]
Hacl.Impl.P256.Point.aff_point_x_as_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.GTot Prims.nat
{ "end_col": 27, "end_line": 50, "start_col": 2, "start_line": 50 }
Prims.GTot
val point_x_as_nat (h: mem) (p: point) : GTot nat
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_x_as_nat (h:mem) (p:point) : GTot nat = as_nat h (gsub p 0ul 4ul)
val point_x_as_nat (h: mem) (p: point) : GTot nat let point_x_as_nat (h: mem) (p: point) : GTot nat =
false
null
false
as_nat h (gsub p 0ul 4ul)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.as_nat", "Lib.Buffer.gsub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.nat" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p) noextract let point_inv (h:mem) (p:point) = point_inv_seq (as_seq h p) noextract
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_x_as_nat (h: mem) (p: point) : GTot nat
[]
Hacl.Impl.P256.Point.point_x_as_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.GTot Prims.nat
{ "end_col": 27, "end_line": 97, "start_col": 2, "start_line": 97 }
Prims.GTot
val point_z_as_nat (h: mem) (e: point) : GTot nat
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_z_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 8ul 4ul)
val point_z_as_nat (h: mem) (e: point) : GTot nat let point_z_as_nat (h: mem) (e: point) : GTot nat =
false
null
false
as_nat h (gsub e 8ul 4ul)
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.as_nat", "Lib.Buffer.gsub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.nat" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p) noextract let point_inv (h:mem) (p:point) = point_inv_seq (as_seq h p) noextract let point_x_as_nat (h:mem) (p:point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let point_y_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 4ul 4ul) noextract
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_z_as_nat (h: mem) (e: point) : GTot nat
[]
Hacl.Impl.P256.Point.point_z_as_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> e: Hacl.Impl.P256.Point.point -> Prims.GTot Prims.nat
{ "end_col": 27, "end_line": 105, "start_col": 2, "start_line": 105 }
FStar.HyperStack.ST.Stack
val aff_gety (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul
val aff_gety (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) let aff_gety (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) =
true
null
false
sub p 4ul 4ul
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[]
[ "Hacl.Impl.P256.Point.aff_point", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Hacl.Impl.P256.Bignum.felem", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Prims.l_and", "Prims.eq2", "Lib.Buffer.buffer_t", "Prims.l_or", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Lib.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Lib.Buffer.gsub" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p)
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_gety (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
[]
Hacl.Impl.P256.Point.aff_gety
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.aff_point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem
{ "end_col": 17, "end_line": 66, "start_col": 4, "start_line": 66 }
FStar.HyperStack.ST.Stack
val getx (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let getx (p:point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul
val getx (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) let getx (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) =
true
null
false
sub p 0ul 4ul
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[]
[ "Hacl.Impl.P256.Point.point", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Hacl.Impl.P256.Bignum.felem", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Prims.l_and", "Prims.eq2", "Lib.Buffer.buffer_t", "Prims.l_or", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Lib.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Lib.Buffer.gsub" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p) noextract let point_inv (h:mem) (p:point) = point_inv_seq (as_seq h p) noextract let point_x_as_nat (h:mem) (p:point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let point_y_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 4ul 4ul) noextract let point_z_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 8ul 4ul) inline_for_extraction noextract let getx (p:point) : Stack felem (requires fun h -> live h p)
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val getx (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
[]
Hacl.Impl.P256.Point.getx
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem
{ "end_col": 17, "end_line": 112, "start_col": 4, "start_line": 112 }
FStar.HyperStack.ST.Stack
val getz (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 8ul 4ul /\ h0 == h1)
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let getz (p:point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 8ul 4ul /\ h0 == h1) = sub p 8ul 4ul
val getz (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 8ul 4ul /\ h0 == h1) let getz (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 8ul 4ul /\ h0 == h1) =
true
null
false
sub p 8ul 4ul
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[]
[ "Hacl.Impl.P256.Point.point", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Hacl.Impl.P256.Bignum.felem", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Prims.l_and", "Prims.eq2", "Lib.Buffer.buffer_t", "Prims.l_or", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Lib.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Lib.Buffer.gsub" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p) noextract let point_inv (h:mem) (p:point) = point_inv_seq (as_seq h p) noextract let point_x_as_nat (h:mem) (p:point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let point_y_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 4ul 4ul) noextract let point_z_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 8ul 4ul) inline_for_extraction noextract let getx (p:point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let gety (p:point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul inline_for_extraction noextract let getz (p:point) : Stack felem (requires fun h -> live h p)
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val getz (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 8ul 4ul /\ h0 == h1)
[]
Hacl.Impl.P256.Point.getz
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem
{ "end_col": 17, "end_line": 124, "start_col": 4, "start_line": 124 }
FStar.HyperStack.ST.Stack
val aff_getx (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul
val aff_getx (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) let aff_getx (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) =
true
null
false
sub p 0ul 4ul
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[]
[ "Hacl.Impl.P256.Point.aff_point", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Hacl.Impl.P256.Bignum.felem", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Prims.l_and", "Prims.eq2", "Lib.Buffer.buffer_t", "Prims.l_or", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Lib.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Lib.Buffer.gsub" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p)
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_getx (p: aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
[]
Hacl.Impl.P256.Point.aff_getx
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.aff_point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem
{ "end_col": 17, "end_line": 60, "start_col": 4, "start_line": 60 }
FStar.HyperStack.ST.Stack
val gety (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gety (p:point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul
val gety (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) let gety (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) =
true
null
false
sub p 4ul 4ul
{ "checked_file": "Hacl.Impl.P256.Point.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Point.fsti" }
[]
[ "Hacl.Impl.P256.Point.point", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Hacl.Impl.P256.Bignum.felem", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Prims.l_and", "Prims.eq2", "Lib.Buffer.buffer_t", "Prims.l_or", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Lib.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Lib.Buffer.gsub" ]
[]
module Hacl.Impl.P256.Point open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module BD = Hacl.Spec.Bignum.Definitions module LSeq = Lib.Sequence #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let from_mont_point (a:tuple3 nat nat nat) : S.proj_point = let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z /// Affine coordinates inline_for_extraction noextract let aff_point_seq = LSeq.lseq uint64 8 let as_aff_point_nat_seq (p:aff_point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) let aff_point_inv_seq (p:aff_point_seq) = let x, y = as_aff_point_nat_seq p in x < S.prime /\ y < S.prime inline_for_extraction noextract let aff_point = lbuffer uint64 8ul noextract let as_aff_point_nat (h:mem) (p:aff_point) = as_aff_point_nat_seq (as_seq h p) noextract let aff_point_inv (h:mem) (p:aff_point) = aff_point_inv_seq (as_seq h p) noextract let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat = as_nat h (gsub p 4ul 4ul) inline_for_extraction noextract let aff_getx (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let aff_gety (p:aff_point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) = sub p 4ul 4ul /// Projective coordinates inline_for_extraction noextract let point_seq = LSeq.lseq uint64 12 let as_point_nat_seq (p:point_seq) = BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) let point_inv_seq (p:point_seq) = let x, y, z = as_point_nat_seq p in x < S.prime /\ y < S.prime /\ z < S.prime inline_for_extraction noextract let point = lbuffer uint64 12ul noextract let as_point_nat (h:mem) (p:point) = as_point_nat_seq (as_seq h p) noextract let point_inv (h:mem) (p:point) = point_inv_seq (as_seq h p) noextract let point_x_as_nat (h:mem) (p:point) : GTot nat = as_nat h (gsub p 0ul 4ul) noextract let point_y_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 4ul 4ul) noextract let point_z_as_nat (h:mem) (e:point) : GTot nat = as_nat h (gsub e 8ul 4ul) inline_for_extraction noextract let getx (p:point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) = sub p 0ul 4ul inline_for_extraction noextract let gety (p:point) : Stack felem (requires fun h -> live h p)
false
false
Hacl.Impl.P256.Point.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gety (p: point) : Stack felem (requires fun h -> live h p) (ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
[]
Hacl.Impl.P256.Point.gety
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem
{ "end_col": 17, "end_line": 118, "start_col": 4, "start_line": 118 }
Prims.GTot
val withlocal_soundness (#g:stt_env) (#t:st_term) (#c:comp) (d:st_typing g t c{T_WithLocal? d}) (soundness:soundness_t d) : GTot (RT.tot_typing (elab_env g) (elab_st_typing d) (elab_comp c))
[ { "abbrev": true, "full_module": "Pulse.Steel.Wrapper.Typing", "short_module": "WT" }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let withlocal_soundness #g #t #c d soundness = let T_WithLocal _ init body init_t c x init_typing init_t_typing c_typing body_typing = d in let CT_ST _ st st_typing = c_typing in let rg = elab_env g in let ru = comp_u c in let ra = elab_term init_t in let rinit = elab_term init in let rpre = elab_term (comp_pre c) in let rret_t = elab_term (comp_res c) in let rpost = elab_term (comp_post c) in let rbody = elab_st_typing body_typing in let a_typing = tot_typing_soundness init_t_typing in let rinit_typing = tot_typing_soundness init_typing in let cres_typing, cpre_typing, cpost_typing = Pulse.Soundness.Comp.stc_soundness st_typing in let pre_typing = cpre_typing in let ret_t_typing = cres_typing in let post_typing = cpost_typing in elab_push_binding g x (mk_array init_t); let rbody_typing = soundness _ _ _ body_typing in WT.with_local_typing #rg #ru #ra #rinit #rpre #rret_t #rpost #rbody x a_typing rinit_typing pre_typing ret_t_typing post_typing rbody_typing
val withlocal_soundness (#g:stt_env) (#t:st_term) (#c:comp) (d:st_typing g t c{T_WithLocal? d}) (soundness:soundness_t d) : GTot (RT.tot_typing (elab_env g) (elab_st_typing d) (elab_comp c)) let withlocal_soundness #g #t #c d soundness =
false
null
false
let T_WithLocal _ init body init_t c x init_typing init_t_typing c_typing body_typing = d in let CT_ST _ st st_typing = c_typing in let rg = elab_env g in let ru = comp_u c in let ra = elab_term init_t in let rinit = elab_term init in let rpre = elab_term (comp_pre c) in let rret_t = elab_term (comp_res c) in let rpost = elab_term (comp_post c) in let rbody = elab_st_typing body_typing in let a_typing = tot_typing_soundness init_t_typing in let rinit_typing = tot_typing_soundness init_typing in let cres_typing, cpre_typing, cpost_typing = Pulse.Soundness.Comp.stc_soundness st_typing in let pre_typing = cpre_typing in let ret_t_typing = cres_typing in let post_typing = cpost_typing in elab_push_binding g x (mk_array init_t); let rbody_typing = soundness _ _ _ body_typing in WT.with_local_typing #rg #ru #ra #rinit #rpre #rret_t #rpost #rbody x a_typing rinit_typing pre_typing ret_t_typing post_typing rbody_typing
{ "checked_file": "Pulse.Soundness.WithLocal.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Steel.Wrapper.Typing.fsti.checked", "Pulse.Soundness.Comp.fsti.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Core.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.WithLocal.fst" }
[ "sometrivial" ]
[ "Pulse.Soundness.Common.stt_env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp", "Pulse.Typing.st_typing", "Prims.b2t", "Pulse.Typing.uu___is_T_WithLocal", "Pulse.Soundness.Common.soundness_t", "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.uu___is_C_ST", "Pulse.Syntax.Base.var", "Prims.l_and", "FStar.Pervasives.Native.uu___is_None", "Pulse.Syntax.Base.typ", "Pulse.Typing.Env.lookup", "Prims.l_not", "FStar.Set.mem", "Pulse.Syntax.Naming.freevars_st", "Pulse.Typing.tot_typing", "Pulse.Typing.universe_of", "Pulse.Syntax.Pure.u0", "Pulse.Typing.comp_typing", "Pulse.Syntax.Base.comp_u", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Typing.mk_ref", "Pulse.Syntax.Naming.open_st_term_nv", "Pulse.Syntax.Base.v_as_nv", "Pulse.Typing.comp_withlocal_body", "Pulse.Syntax.Base.st_comp", "Pulse.Typing.st_comp_typing", "FStar.Reflection.Typing.tot_typing", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "FStar.Reflection.Typing.tm_type", "Pulse.Syntax.Base.__proj__Mkst_comp__item__u", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_abs", "FStar.Reflection.V2.Data.Q_Explicit", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Pulse.Soundness.Common.post1_type_bind", "Pulse.Steel.Wrapper.Typing.with_local_typing", "Pulse.Elaborate.Core.elab_st_typing", "Pulse.Elaborate.Pure.elab_comp", "Prims.unit", "Pulse.Typing.elab_push_binding", "Pulse.Typing.mk_array", "FStar.Pervasives.Native.tuple3", "Pulse.Soundness.Comp.stc_soundness", "Pulse.Soundness.Common.tot_typing_soundness", "Pulse.Syntax.Pure.tm_type", "FStar.Reflection.Types.term", "Pulse.Syntax.Base.comp_post", "Pulse.Syntax.Base.comp_res", "Pulse.Syntax.Base.comp_pre", "Pulse.Syntax.Base.universe", "FStar.Reflection.Types.env" ]
[]
module Pulse.Soundness.WithLocal open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate.Core open Pulse.Elaborate open Pulse.Soundness.Common module WT = Pulse.Steel.Wrapper.Typing
false
false
Pulse.Soundness.WithLocal.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 8, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 8, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val withlocal_soundness (#g:stt_env) (#t:st_term) (#c:comp) (d:st_typing g t c{T_WithLocal? d}) (soundness:soundness_t d) : GTot (RT.tot_typing (elab_env g) (elab_st_typing d) (elab_comp c))
[]
Pulse.Soundness.WithLocal.withlocal_soundness
{ "file_name": "lib/steel/pulse/Pulse.Soundness.WithLocal.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.st_typing g t c {T_WithLocal? d} -> soundness: Pulse.Soundness.Common.soundness_t d -> Prims.GTot (FStar.Reflection.Typing.tot_typing (Pulse.Typing.elab_env g) (Pulse.Elaborate.Core.elab_st_typing d) (Pulse.Elaborate.Pure.elab_comp c))
{ "end_col": 16, "end_line": 53, "start_col": 46, "start_line": 13 }
Prims.Tot
val has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a) : prop
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs
val has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a) : prop let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a) : prop =
false
null
false
forall x. f x == x `FLT.mem` xs
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FunctionalExtensionality.op_Hat_Subtraction_Greater", "Prims.bool", "Prims.list", "Prims.l_Forall", "Prims.eq2", "FStar.List.Tot.Base.mem", "Prims.prop" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a) : prop
[]
FStar.FiniteSet.Base.has_elements
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: a ^-> Prims.bool -> xs: Prims.list a -> Prims.prop
{ "end_col": 33, "end_line": 43, "start_col": 2, "start_line": 43 }
Prims.GTot
val cardinality (#a: eqtype) (s: set a) : GTot nat
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s)
val cardinality (#a: eqtype) (s: set a) : GTot nat let cardinality (#a: eqtype) (s: set a) : GTot nat =
false
null
false
FLT.length (set_as_list s)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "sometrivial" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.List.Tot.Base.length", "FStar.FiniteSet.Base.set_as_list", "Prims.nat" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"]
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cardinality (#a: eqtype) (s: set a) : GTot nat
[]
FStar.FiniteSet.Base.cardinality
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.FiniteSet.Base.set a -> Prims.GTot Prims.nat
{ "end_col": 28, "end_line": 68, "start_col": 2, "start_line": 68 }
Prims.Tot
val mem (#a: eqtype) (x: a) (s: set a) : bool
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mem (#a: eqtype) (x: a) (s: set a) : bool = s x
val mem (#a: eqtype) (x: a) (s: set a) : bool let mem (#a: eqtype) (x: a) (s: set a) : bool =
false
null
false
s x
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.bool" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`:
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mem (#a: eqtype) (x: a) (s: set a) : bool
[]
FStar.FiniteSet.Base.mem
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> s: FStar.FiniteSet.Base.set a -> Prims.bool
{ "end_col": 5, "end_line": 51, "start_col": 2, "start_line": 51 }
Prims.Tot
val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true)
val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 let subset (#a: eqtype) (s1 s2: set a) : Type0 =
false
null
false
forall x. (s1 x = true) ==> (s2 x = true)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.bool" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool;
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0
[]
FStar.FiniteSet.Base.subset
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> Type0
{ "end_col": 43, "end_line": 138, "start_col": 2, "start_line": 138 }
Prims.Tot
val singleton (#a: eqtype) (x: a) : set a
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let singleton (#a: eqtype) (x: a) : set a = insert x emptyset
val singleton (#a: eqtype) (x: a) : set a let singleton (#a: eqtype) (x: a) : set a =
false
null
false
insert x emptyset
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.insert", "FStar.FiniteSet.Base.emptyset", "FStar.FiniteSet.Base.set" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T;
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val singleton (#a: eqtype) (x: a) : set a
[]
FStar.FiniteSet.Base.singleton
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> FStar.FiniteSet.Base.set a
{ "end_col": 19, "end_line": 93, "start_col": 2, "start_line": 93 }
Prims.Tot
val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2
val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 let equal (#a: eqtype) (s1 s2: set a) : Type0 =
false
null
false
feq s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FunctionalExtensionality.feq", "Prims.bool" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool;
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0
[]
FStar.FiniteSet.Base.equal
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> Type0
{ "end_col": 11, "end_line": 145, "start_col": 2, "start_line": 145 }
Prims.Tot
val union (#a: eqtype) (s1: set a) (s2: set a) : (set a)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2))
val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) let union (#a: eqtype) (s1 s2: set a) : (set a) =
false
null
false
intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.intro_set", "FStar.FunctionalExtensionality.on_dom", "Prims.bool", "Prims.op_BarBar", "FStar.Ghost.hide", "Prims.list", "FStar.FiniteSet.Base.union_lists", "FStar.FiniteSet.Base.set_as_list" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union (#a: eqtype) (s1: set a) (s2: set a) : (set a)
[]
FStar.FiniteSet.Base.union
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> FStar.FiniteSet.Base.set a
{ "end_col": 94, "end_line": 105, "start_col": 2, "start_line": 105 }
Prims.GTot
val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)})
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s))
val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) let set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a {list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) =
false
null
false
remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "sometrivial" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.remove_repeats", "FStar.IndefiniteDescription.indefinite_description_ghost", "Prims.list", "Prims.l_Forall", "Prims.b2t", "Prims.op_Equality", "Prims.bool", "FStar.List.Tot.Base.mem", "FStar.FiniteSet.Base.mem", "Prims.prop", "Prims.l_and", "FStar.FiniteSet.Base.list_nonrepeating" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl'
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)})
[]
FStar.FiniteSet.Base.set_as_list
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.FiniteSet.Base.set a -> Prims.GTot (xs: Prims.list a { FStar.FiniteSet.Base.list_nonrepeating xs /\ (forall (x: a). FStar.List.Tot.Base.mem x xs = FStar.FiniteSet.Base.mem x s) })
{ "end_col": 129, "end_line": 64, "start_col": 2, "start_line": 64 }
Prims.Tot
val difference (#a: eqtype) (s1: set a) (s2: set a) : set a
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2))
val difference (#a: eqtype) (s1: set a) (s2: set a) : set a let difference (#a: eqtype) (s1 s2: set a) : set a =
false
null
false
intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.intro_set", "FStar.FunctionalExtensionality.on_dom", "Prims.bool", "Prims.op_AmpAmp", "Prims.op_Negation", "FStar.Ghost.hide", "Prims.list", "FStar.FiniteSet.Base.difference_lists", "FStar.FiniteSet.Base.set_as_list" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs'
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val difference (#a: eqtype) (s1: set a) (s2: set a) : set a
[]
FStar.FiniteSet.Base.difference
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> FStar.FiniteSet.Base.set a
{ "end_col": 105, "end_line": 131, "start_col": 2, "start_line": 131 }
Prims.Pure
val intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f
val intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) =
false
null
false
Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[]
[ "Prims.eqtype", "FStar.FunctionalExtensionality.op_Hat_Subtraction_Greater", "Prims.bool", "FStar.Ghost.erased", "Prims.list", "Prims.unit", "FStar.Classical.exists_intro", "FStar.FiniteSet.Base.has_elements", "FStar.Ghost.reveal", "FStar.FiniteSet.Base.set", "Prims.l_True" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True)
[]
FStar.FiniteSet.Base.intro_set
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: a ^-> Prims.bool -> xs: FStar.Ghost.erased (Prims.list a) -> Prims.Pure (FStar.FiniteSet.Base.set a)
{ "end_col": 3, "end_line": 75, "start_col": 2, "start_line": 74 }
Prims.Tot
val insert (#a: eqtype) (x: a) (s: set a) : set a
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s)
val insert (#a: eqtype) (x: a) (s: set a) : set a let insert (#a: eqtype) (x: a) (s: set a) : set a =
false
null
false
intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.intro_set", "FStar.FunctionalExtensionality.on_dom", "Prims.bool", "Prims.op_BarBar", "Prims.op_Equality", "FStar.Ghost.hide", "Prims.list", "Prims.Cons", "FStar.FiniteSet.Base.set_as_list" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T;
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val insert (#a: eqtype) (x: a) (s: set a) : set a
[]
FStar.FiniteSet.Base.insert
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> s: FStar.FiniteSet.Base.set a -> FStar.FiniteSet.Base.set a
{ "end_col": 70, "end_line": 86, "start_col": 2, "start_line": 86 }
Prims.GTot
val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s})
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s)
val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) let choose (#a: eqtype) (s: set a {exists x. mem x s}) : GTot (x: a{mem x s}) =
false
null
false
Cons?.hd (set_as_list s)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "sometrivial" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_Exists", "Prims.b2t", "FStar.FiniteSet.Base.mem", "Prims.__proj__Cons__item__hd", "FStar.FiniteSet.Base.set_as_list" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s;
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s})
[]
FStar.FiniteSet.Base.choose
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.FiniteSet.Base.set a {exists (x: a). FStar.FiniteSet.Base.mem x s} -> Prims.GTot (x: a{FStar.FiniteSet.Base.mem x s})
{ "end_col": 26, "end_line": 159, "start_col": 2, "start_line": 159 }
Prims.Tot
val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2))
val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a let intersection (#a: eqtype) (s1 s2: set a) : set a =
false
null
false
intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.intro_set", "FStar.FunctionalExtensionality.on_dom", "Prims.bool", "Prims.op_AmpAmp", "FStar.Ghost.hide", "Prims.list", "FStar.FiniteSet.Base.intersect_lists", "FStar.FiniteSet.Base.set_as_list" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs'
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a
[]
FStar.FiniteSet.Base.intersection
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> FStar.FiniteSet.Base.set a
{ "end_col": 98, "end_line": 118, "start_col": 2, "start_line": 118 }
Prims.Tot
val remove_repeats (#a: eqtype) (xs: list a) : (ys: list a {list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)})
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl'
val remove_repeats (#a: eqtype) (xs: list a) : (ys: list a {list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a {list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) =
false
null
false
match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl'
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.list", "Prims.Nil", "FStar.List.Tot.Base.mem", "Prims.bool", "Prims.Cons", "Prims.l_and", "Prims.b2t", "FStar.FiniteSet.Base.list_nonrepeating", "Prims.l_Forall", "Prims.l_iff", "FStar.FiniteSet.Base.remove_repeats" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val remove_repeats (#a: eqtype) (xs: list a) : (ys: list a {list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)})
[ "recursion" ]
FStar.FiniteSet.Base.remove_repeats
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
xs: Prims.list a -> ys: Prims.list a { FStar.FiniteSet.Base.list_nonrepeating ys /\ (forall (y: a). FStar.List.Tot.Base.mem y ys <==> FStar.List.Tot.Base.mem y xs) }
{ "end_col": 87, "end_line": 61, "start_col": 2, "start_line": 59 }
Prims.Tot
val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x)
val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 let disjoint (#a: eqtype) (s1 s2: set a) : Type0 =
false
null
false
forall x. not (s1 x && s2 x)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_Forall", "Prims.b2t", "Prims.op_Negation", "Prims.op_AmpAmp" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool;
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0
[]
FStar.FiniteSet.Base.disjoint
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> Type0
{ "end_col": 30, "end_line": 152, "start_col": 2, "start_line": 152 }
Prims.Tot
val intersect_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys})
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs'
val intersect_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) let rec intersect_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) =
false
null
false
match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs'
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.list", "Prims.Nil", "FStar.List.Tot.Base.mem", "Prims.Cons", "Prims.bool", "Prims.l_Forall", "Prims.l_iff", "Prims.b2t", "Prims.l_and", "FStar.FiniteSet.Base.intersect_lists" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intersect_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys})
[ "recursion" ]
FStar.FiniteSet.Base.intersect_lists
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
xs: Prims.list a -> ys: Prims.list a -> zs: Prims.list a { forall (z: a). FStar.List.Tot.Base.mem z zs <==> FStar.List.Tot.Base.mem z xs /\ FStar.List.Tot.Base.mem z ys }
{ "end_col": 91, "end_line": 115, "start_col": 2, "start_line": 113 }
Prims.Tot
val emptyset (#a: eqtype) : set a
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) []
val emptyset (#a: eqtype) : set a let emptyset (#a: eqtype) : set a =
false
null
false
intro_set (on_dom a (fun _ -> false)) []
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.intro_set", "FStar.FunctionalExtensionality.on_dom", "Prims.bool", "FStar.Ghost.hide", "Prims.list", "Prims.Nil", "FStar.FiniteSet.Base.set" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`:
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emptyset (#a: eqtype) : set a
[]
FStar.FiniteSet.Base.emptyset
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.FiniteSet.Base.set a
{ "end_col": 75, "end_line": 79, "start_col": 35, "start_line": 79 }
FStar.Pervasives.Lemma
val intersection_cardinality_lemma: Prims.unit -> Lemma (intersection_cardinality_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2
val intersection_cardinality_lemma: Prims.unit -> Lemma (intersection_cardinality_fact) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Addition", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.union", "FStar.FiniteSet.Base.intersection", "FStar.FiniteSet.Base.intersection_cardinality_helper", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.intersection_cardinality_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intersection_cardinality_lemma: Prims.unit -> Lemma (intersection_cardinality_fact)
[]
FStar.FiniteSet.Base.intersection_cardinality_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.intersection_cardinality_fact)
{ "end_col": 43, "end_line": 345, "start_col": 2, "start_line": 342 }
FStar.Pervasives.Lemma
val remove_insert_lemma: Prims.unit -> Lemma (remove_insert_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let remove_insert_lemma () : Lemma (remove_insert_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = false ==> remove x (insert x s) == s with introduce mem x s = false ==> remove x (insert x s) == s with _. remove_insert_helper a x s
val remove_insert_lemma: Prims.unit -> Lemma (remove_insert_fact) let remove_insert_lemma () : Lemma (remove_insert_fact) =
false
null
true
introduce forall (a: eqtype) (x: a) (s: set a) . mem x s = false ==> remove x (insert x s) == s with introduce mem x s = false ==> remove x (insert x s) == s with _. remove_insert_helper a x s
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.bool", "FStar.FiniteSet.Base.mem", "Prims.eq2", "FStar.FiniteSet.Base.remove", "FStar.FiniteSet.Base.insert", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.FiniteSet.Base.remove_insert_helper", "Prims.l_True", "FStar.FiniteSet.Base.remove_insert_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) ) let equal_extensionality_lemma () : Lemma (equal_extensionality_fact) = () let disjoint_lemma () : Lemma (disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. ( introduce forall x. not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2)) ) ) let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) = assert (feq s (insert x (remove x s))) let insert_remove_lemma () : Lemma (insert_remove_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = true ==> insert x (remove x s) == s with introduce mem x s = true ==> insert x (remove x s) == s with _. insert_remove_helper a x s let remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s) = assert (feq s (remove x (insert x s))) let remove_insert_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val remove_insert_lemma: Prims.unit -> Lemma (remove_insert_fact)
[]
FStar.FiniteSet.Base.remove_insert_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.remove_insert_fact)
{ "end_col": 36, "end_line": 431, "start_col": 2, "start_line": 429 }
FStar.Pervasives.Lemma
val subset_lemma: Prims.unit -> Lemma (subset_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2
val subset_lemma: Prims.unit -> Lemma (subset_fact) let subset_lemma () : Lemma (subset_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . subset s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_iff", "FStar.FiniteSet.Base.subset", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.subset_helper", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.subset_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subset_lemma: Prims.unit -> Lemma (subset_fact)
[]
FStar.FiniteSet.Base.subset_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.subset_fact)
{ "end_col": 28, "end_line": 381, "start_col": 2, "start_line": 380 }
FStar.Pervasives.Lemma
val difference_cardinality_lemma: Prims.unit -> Lemma (difference_cardinality_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2
val difference_cardinality_lemma: Prims.unit -> Lemma (difference_cardinality_fact) let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Addition", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.difference", "FStar.FiniteSet.Base.intersection", "FStar.FiniteSet.Base.union", "Prims.op_Subtraction", "FStar.FiniteSet.Base.difference_cardinality_helper", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.difference_cardinality_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val difference_cardinality_lemma: Prims.unit -> Lemma (difference_cardinality_fact)
[]
FStar.FiniteSet.Base.difference_cardinality_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.difference_cardinality_fact)
{ "end_col": 41, "end_line": 369, "start_col": 2, "start_line": 364 }
FStar.Pervasives.Lemma
val all_finite_set_facts_lemma : unit -> Lemma (all_finite_set_facts)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let all_finite_set_facts_lemma () : Lemma (all_finite_set_facts) = empty_set_contains_no_elements_lemma (); length_zero_lemma (); singleton_contains_argument_lemma (); singleton_contains_lemma (); singleton_cardinality_lemma (); insert_lemma (); insert_contains_argument_lemma (); insert_contains_lemma (); insert_member_cardinality_lemma (); insert_nonmember_cardinality_lemma (); union_contains_lemma (); union_contains_element_from_first_argument_lemma (); union_contains_element_from_second_argument_lemma (); union_of_disjoint_lemma (); intersection_contains_lemma (); union_idempotent_right_lemma (); union_idempotent_left_lemma (); intersection_idempotent_right_lemma (); intersection_idempotent_left_lemma (); intersection_cardinality_lemma (); difference_contains_lemma (); difference_doesnt_include_lemma (); difference_cardinality_lemma (); subset_lemma (); equal_lemma (); equal_extensionality_lemma (); disjoint_lemma (); insert_remove_lemma (); remove_insert_lemma (); set_as_list_cardinality_lemma ()
val all_finite_set_facts_lemma : unit -> Lemma (all_finite_set_facts) let all_finite_set_facts_lemma () : Lemma (all_finite_set_facts) =
false
null
true
empty_set_contains_no_elements_lemma (); length_zero_lemma (); singleton_contains_argument_lemma (); singleton_contains_lemma (); singleton_cardinality_lemma (); insert_lemma (); insert_contains_argument_lemma (); insert_contains_lemma (); insert_member_cardinality_lemma (); insert_nonmember_cardinality_lemma (); union_contains_lemma (); union_contains_element_from_first_argument_lemma (); union_contains_element_from_second_argument_lemma (); union_of_disjoint_lemma (); intersection_contains_lemma (); union_idempotent_right_lemma (); union_idempotent_left_lemma (); intersection_idempotent_right_lemma (); intersection_idempotent_left_lemma (); intersection_cardinality_lemma (); difference_contains_lemma (); difference_doesnt_include_lemma (); difference_cardinality_lemma (); subset_lemma (); equal_lemma (); equal_extensionality_lemma (); disjoint_lemma (); insert_remove_lemma (); remove_insert_lemma (); set_as_list_cardinality_lemma ()
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.FiniteSet.Base.set_as_list_cardinality_lemma", "FStar.FiniteSet.Base.remove_insert_lemma", "FStar.FiniteSet.Base.insert_remove_lemma", "FStar.FiniteSet.Base.disjoint_lemma", "FStar.FiniteSet.Base.equal_extensionality_lemma", "FStar.FiniteSet.Base.equal_lemma", "FStar.FiniteSet.Base.subset_lemma", "FStar.FiniteSet.Base.difference_cardinality_lemma", "FStar.FiniteSet.Base.difference_doesnt_include_lemma", "FStar.FiniteSet.Base.difference_contains_lemma", "FStar.FiniteSet.Base.intersection_cardinality_lemma", "FStar.FiniteSet.Base.intersection_idempotent_left_lemma", "FStar.FiniteSet.Base.intersection_idempotent_right_lemma", "FStar.FiniteSet.Base.union_idempotent_left_lemma", "FStar.FiniteSet.Base.union_idempotent_right_lemma", "FStar.FiniteSet.Base.intersection_contains_lemma", "FStar.FiniteSet.Base.union_of_disjoint_lemma", "FStar.FiniteSet.Base.union_contains_element_from_second_argument_lemma", "FStar.FiniteSet.Base.union_contains_element_from_first_argument_lemma", "FStar.FiniteSet.Base.union_contains_lemma", "FStar.FiniteSet.Base.insert_nonmember_cardinality_lemma", "FStar.FiniteSet.Base.insert_member_cardinality_lemma", "FStar.FiniteSet.Base.insert_contains_lemma", "FStar.FiniteSet.Base.insert_contains_argument_lemma", "FStar.FiniteSet.Base.insert_lemma", "FStar.FiniteSet.Base.singleton_cardinality_lemma", "FStar.FiniteSet.Base.singleton_contains_lemma", "FStar.FiniteSet.Base.singleton_contains_argument_lemma", "FStar.FiniteSet.Base.length_zero_lemma", "FStar.FiniteSet.Base.empty_set_contains_no_elements_lemma", "Prims.l_True", "Prims.squash", "FStar.FiniteSet.Base.all_finite_set_facts", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) ) let equal_extensionality_lemma () : Lemma (equal_extensionality_fact) = () let disjoint_lemma () : Lemma (disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. ( introduce forall x. not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2)) ) ) let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) = assert (feq s (insert x (remove x s))) let insert_remove_lemma () : Lemma (insert_remove_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = true ==> insert x (remove x s) == s with introduce mem x s = true ==> insert x (remove x s) == s with _. insert_remove_helper a x s let remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s) = assert (feq s (remove x (insert x s))) let remove_insert_lemma () : Lemma (remove_insert_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = false ==> remove x (insert x s) == s with introduce mem x s = false ==> remove x (insert x s) == s with _. remove_insert_helper a x s let set_as_list_cardinality_lemma () : Lemma (set_as_list_cardinality_fact) = introduce forall (a: eqtype) (s: set a). FLT.length (set_as_list s) = cardinality s with reveal_opaque (`%cardinality) (cardinality #a)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val all_finite_set_facts_lemma : unit -> Lemma (all_finite_set_facts)
[]
FStar.FiniteSet.Base.all_finite_set_facts_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.all_finite_set_facts)
{ "end_col": 34, "end_line": 468, "start_col": 2, "start_line": 439 }
FStar.Pervasives.Lemma
val insert_member_cardinality_lemma: Prims.unit -> Lemma (insert_member_cardinality_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) )
val insert_member_cardinality_lemma: Prims.unit -> Lemma (insert_member_cardinality_fact) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) =
false
null
true
introduce forall (a: eqtype) (s: set a) (x: a) . mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. (reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "Prims.op_Equality", "Prims.nat", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.insert", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.FiniteSet.Base.nonrepeating_lists_with_same_elements_have_same_length", "FStar.FiniteSet.Base.set_as_list", "FStar.Pervasives.reveal_opaque", "Prims.l_True", "FStar.FiniteSet.Base.insert_member_cardinality_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val insert_member_cardinality_lemma: Prims.unit -> Lemma (insert_member_cardinality_fact)
[]
FStar.FiniteSet.Base.insert_member_cardinality_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.insert_member_cardinality_fact)
{ "end_col": 5, "end_line": 242, "start_col": 2, "start_line": 236 }
FStar.Pervasives.Lemma
val union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2))
val union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) =
false
null
true
reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.union_of_disjoint_nonrepeating_lists_length_lemma", "FStar.FiniteSet.Base.set_as_list", "FStar.FiniteSet.Base.union", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Prims.nat", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.disjoint", "Prims.squash", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2)
[]
FStar.FiniteSet.Base.union_of_disjoint_sets_cardinality_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> FStar.Pervasives.Lemma (requires FStar.FiniteSet.Base.disjoint s1 s2) (ensures FStar.FiniteSet.Base.cardinality (FStar.FiniteSet.Base.union s1 s2) = FStar.FiniteSet.Base.cardinality s1 + FStar.FiniteSet.Base.cardinality s2)
{ "end_col": 113, "end_line": 315, "start_col": 2, "start_line": 314 }
Prims.Tot
val remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a {FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a { list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x) })
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl)
val remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a {FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a { list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x) }) let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a {FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a { list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x) }) =
false
null
false
match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.list", "Prims.l_and", "Prims.b2t", "FStar.List.Tot.Base.mem", "FStar.FiniteSet.Base.list_nonrepeating", "Prims.op_Equality", "Prims.bool", "Prims.Cons", "FStar.FiniteSet.Base.remove_from_nonrepeating_list", "Prims.int", "FStar.List.Tot.Base.length", "Prims.op_Subtraction", "Prims.l_Forall", "Prims.l_iff", "Prims.op_disEquality" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a {FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a { list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x) })
[ "recursion" ]
FStar.FiniteSet.Base.remove_from_nonrepeating_list
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> xs: Prims.list a {FStar.List.Tot.Base.mem x xs /\ FStar.FiniteSet.Base.list_nonrepeating xs} -> xs': Prims.list a { FStar.FiniteSet.Base.list_nonrepeating xs' /\ FStar.List.Tot.Base.length xs' = FStar.List.Tot.Base.length xs - 1 /\ (forall (y: a). FStar.List.Tot.Base.mem y xs' <==> FStar.List.Tot.Base.mem y xs /\ y <> x) }
{ "end_col": 81, "end_line": 225, "start_col": 2, "start_line": 224 }
FStar.Pervasives.Lemma
val union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2 s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3
val union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2 s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2 s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) =
false
null
true
union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.union_of_disjoint_sets_cardinality_lemma", "FStar.FiniteSet.Base.union", "Prims.unit", "Prims.l_and", "FStar.FiniteSet.Base.disjoint", "Prims.squash", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.FiniteSet.Base.cardinality", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1 s2 s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3)
[]
FStar.FiniteSet.Base.union_of_three_disjoint_sets_cardinality_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> s3: FStar.FiniteSet.Base.set a -> FStar.Pervasives.Lemma (requires FStar.FiniteSet.Base.disjoint s1 s2 /\ FStar.FiniteSet.Base.disjoint s2 s3 /\ FStar.FiniteSet.Base.disjoint s1 s3) (ensures FStar.FiniteSet.Base.cardinality (FStar.FiniteSet.Base.union (FStar.FiniteSet.Base.union s1 s2) s3) = FStar.FiniteSet.Base.cardinality s1 + FStar.FiniteSet.Base.cardinality s2 + FStar.FiniteSet.Base.cardinality s3)
{ "end_col": 59, "end_line": 321, "start_col": 2, "start_line": 320 }
FStar.Pervasives.Lemma
val subset_helper (a: eqtype) (s1 s2: set a) : Lemma (subset s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 ==> mem o s2))
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x)
val subset_helper (a: eqtype) (s1 s2: set a) : Lemma (subset s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 ==> mem o s2)) let subset_helper (a: eqtype) (s1 s2: set a) : Lemma (subset s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 ==> mem o s2)) =
false
null
true
introduce (forall o. {:pattern mem o s1\/mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x . s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.Classical.Sugar.implies_intro", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "Prims.squash", "FStar.FiniteSet.Base.subset", "FStar.Classical.Sugar.forall_intro", "Prims.op_Equality", "Prims.bool", "Prims._assert", "Prims.unit", "Prims.l_True", "Prims.l_iff", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subset_helper (a: eqtype) (s1 s2: set a) : Lemma (subset s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 ==> mem o s2))
[]
FStar.FiniteSet.Base.subset_helper
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Prims.eqtype -> s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.subset s1 s2 <==> (forall (o: a). {:pattern FStar.FiniteSet.Base.mem o s1\/FStar.FiniteSet.Base.mem o s2} FStar.FiniteSet.Base.mem o s1 ==> FStar.FiniteSet.Base.mem o s2))
{ "end_col": 33, "end_line": 376, "start_col": 2, "start_line": 373 }
Prims.Tot
val difference_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)})
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs'
val difference_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) let rec difference_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) =
false
null
false
match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs'
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.list", "Prims.Nil", "FStar.List.Tot.Base.mem", "Prims.bool", "Prims.Cons", "Prims.l_Forall", "Prims.l_iff", "Prims.b2t", "Prims.l_and", "Prims.l_not", "FStar.FiniteSet.Base.difference_lists" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val difference_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)})
[ "recursion" ]
FStar.FiniteSet.Base.difference_lists
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
xs: Prims.list a -> ys: Prims.list a -> zs: Prims.list a { forall (z: a). FStar.List.Tot.Base.mem z zs <==> FStar.List.Tot.Base.mem z xs /\ ~(FStar.List.Tot.Base.mem z ys) }
{ "end_col": 92, "end_line": 128, "start_col": 2, "start_line": 126 }
FStar.Pervasives.Lemma
val equal_lemma: Prims.unit -> Lemma (equal_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) )
val equal_lemma: Prims.unit -> Lemma (equal_fact) let equal_lemma () : Lemma (equal_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . equal s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 <==> mem o s2) with (introduce (forall o. {:pattern mem o s1\/mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x . s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_iff", "FStar.FiniteSet.Base.equal", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "Prims.op_Equality", "Prims.bool", "Prims._assert", "Prims.l_and", "Prims.l_True", "FStar.FiniteSet.Base.equal_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val equal_lemma: Prims.unit -> Lemma (equal_fact)
[]
FStar.FiniteSet.Base.equal_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.equal_fact)
{ "end_col": 3, "end_line": 392, "start_col": 2, "start_line": 385 }
FStar.Pervasives.Lemma
val singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r])
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl
val singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) =
false
null
true
match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.FiniteSet.Base.singleton_cardinality_helper", "Prims.unit", "Prims._assert", "Prims.b2t", "Prims.op_Equality", "Prims.__proj__Cons__item__hd", "Prims.l_and", "FStar.List.Tot.Base.mem", "Prims.l_Forall", "Prims.l_iff", "Prims.squash", "Prims.eq2", "FStar.FiniteSet.Base.remove_repeats", "Prims.Cons", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r))
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r])
[ "recursion" ]
FStar.FiniteSet.Base.singleton_cardinality_helper
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: a -> xs: Prims.list a -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.mem r xs /\ (forall (x: a). FStar.List.Tot.Base.mem x xs <==> x = r)) (ensures FStar.FiniteSet.Base.remove_repeats xs == [r])
{ "end_col": 39, "end_line": 198, "start_col": 2, "start_line": 194 }
Prims.Tot
val union_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys})
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys
val union_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) let rec union_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) =
false
null
false
match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.list", "Prims.Cons", "FStar.FiniteSet.Base.union_lists", "Prims.l_Forall", "Prims.l_iff", "Prims.b2t", "FStar.List.Tot.Base.mem", "Prims.l_or" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T;
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_lists (#a: eqtype) (xs ys: list a) : (zs: list a {forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys})
[ "recursion" ]
FStar.FiniteSet.Base.union_lists
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
xs: Prims.list a -> ys: Prims.list a -> zs: Prims.list a { forall (z: a). FStar.List.Tot.Base.mem z zs <==> FStar.List.Tot.Base.mem z xs \/ FStar.List.Tot.Base.mem z ys }
{ "end_col": 39, "end_line": 102, "start_col": 2, "start_line": 100 }
FStar.Pervasives.Lemma
val disjoint_lemma: Prims.unit -> Lemma (disjoint_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let disjoint_lemma () : Lemma (disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. ( introduce forall x. not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2)) ) )
val disjoint_lemma: Prims.unit -> Lemma (disjoint_fact) let disjoint_lemma () : Lemma (disjoint_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . disjoint s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} not (mem o s1) \/ not (mem o s2)) with (introduce (forall o. {:pattern mem o s1\/mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. (introduce forall x . not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2))))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_iff", "FStar.FiniteSet.Base.disjoint", "Prims.l_or", "Prims.b2t", "Prims.op_Negation", "FStar.FiniteSet.Base.mem", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "Prims.op_AmpAmp", "Prims._assert", "Prims.l_True", "FStar.FiniteSet.Base.disjoint_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) ) let equal_extensionality_lemma () : Lemma (equal_extensionality_fact) = () let disjoint_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val disjoint_lemma: Prims.unit -> Lemma (disjoint_fact)
[]
FStar.FiniteSet.Base.disjoint_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.disjoint_fact)
{ "end_col": 3, "end_line": 408, "start_col": 2, "start_line": 400 }
FStar.Pervasives.Lemma
val length_zero_lemma: Prims.unit -> Lemma (length_zero_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ())
val length_zero_lemma: Prims.unit -> Lemma (length_zero_fact) let length_zero_lemma () : Lemma (length_zero_fact) =
false
null
true
introduce forall (a: eqtype) (s: set a) . (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with (reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x.mem x s with (Cons?.hd (set_as_list s)) and ())
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_and", "Prims.l_iff", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.FiniteSet.Base.cardinality", "Prims.eq2", "FStar.FiniteSet.Base.emptyset", "Prims.op_disEquality", "Prims.l_Exists", "FStar.FiniteSet.Base.mem", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.Classical.Sugar.exists_intro", "Prims.__proj__Cons__item__hd", "FStar.FiniteSet.Base.set_as_list", "Prims._assert", "Prims.list", "Prims.Nil", "FStar.FunctionalExtensionality.feq", "Prims.bool", "FStar.Pervasives.reveal_opaque", "Prims.nat", "Prims.l_True", "FStar.FiniteSet.Base.length_zero_fact", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length_zero_lemma: Prims.unit -> Lemma (length_zero_fact)
[]
FStar.FiniteSet.Base.length_zero_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.length_zero_fact)
{ "end_col": 20, "end_line": 181, "start_col": 2, "start_line": 171 }
FStar.Pervasives.Lemma
val union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1 xs2 xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3)
val union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1 xs2 xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1 xs2 xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) =
false
null
true
match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.FiniteSet.Base.nonrepeating_lists_with_same_elements_have_same_length", "FStar.FiniteSet.Base.union_of_disjoint_nonrepeating_lists_length_lemma", "FStar.FiniteSet.Base.remove_from_nonrepeating_list", "Prims.unit", "Prims.l_and", "Prims.b2t", "FStar.FiniteSet.Base.list_nonrepeating", "Prims.l_Forall", "Prims.l_not", "FStar.List.Tot.Base.mem", "Prims.l_iff", "Prims.l_or", "Prims.squash", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2))
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1 xs2 xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2)
[ "recursion" ]
FStar.FiniteSet.Base.union_of_disjoint_nonrepeating_lists_length_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
xs1: Prims.list a -> xs2: Prims.list a -> xs3: Prims.list a -> FStar.Pervasives.Lemma (requires FStar.FiniteSet.Base.list_nonrepeating xs1 /\ FStar.FiniteSet.Base.list_nonrepeating xs2 /\ FStar.FiniteSet.Base.list_nonrepeating xs3 /\ (forall (x: a). ~(FStar.List.Tot.Base.mem x xs1 /\ FStar.List.Tot.Base.mem x xs2)) /\ (forall (x: a). FStar.List.Tot.Base.mem x xs3 <==> FStar.List.Tot.Base.mem x xs1 \/ FStar.List.Tot.Base.mem x xs2)) (ensures FStar.List.Tot.Base.length xs3 = FStar.List.Tot.Base.length xs1 + FStar.List.Tot.Base.length xs2)
{ "end_col": 111, "end_line": 309, "start_col": 2, "start_line": 307 }
FStar.Pervasives.Lemma
val nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1 s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2)
val nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1 s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1 s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) =
false
null
true
match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "Prims.list", "FStar.FiniteSet.Base.nonrepeating_lists_with_same_elements_have_same_length", "FStar.FiniteSet.Base.remove_from_nonrepeating_list", "Prims.unit", "Prims.l_and", "Prims.b2t", "FStar.FiniteSet.Base.list_nonrepeating", "Prims.l_Forall", "Prims.l_iff", "FStar.List.Tot.Base.mem", "Prims.squash", "Prims.op_Equality", "Prims.nat", "FStar.List.Tot.Base.length", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2))
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1 s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2)
[ "recursion" ]
FStar.FiniteSet.Base.nonrepeating_lists_with_same_elements_have_same_length
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: Prims.list a -> s2: Prims.list a -> FStar.Pervasives.Lemma (requires FStar.FiniteSet.Base.list_nonrepeating s1 /\ FStar.FiniteSet.Base.list_nonrepeating s2 /\ (forall (x: a). FStar.List.Tot.Base.mem x s1 <==> FStar.List.Tot.Base.mem x s2)) (ensures FStar.List.Tot.Base.length s1 = FStar.List.Tot.Base.length s2)
{ "end_col": 111, "end_line": 232, "start_col": 2, "start_line": 230 }
FStar.Pervasives.Lemma
val intersection_idempotent_left_lemma: Prims.unit -> Lemma (intersection_idempotent_left_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2))
val intersection_idempotent_left_lemma: Prims.unit -> Lemma (intersection_idempotent_left_fact) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.intersection", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.intersection_idempotent_left_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intersection_idempotent_left_lemma: Prims.unit -> Lemma (intersection_idempotent_left_fact)
[]
FStar.FiniteSet.Base.intersection_idempotent_left_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.intersection_idempotent_left_fact)
{ "end_col": 79, "end_line": 298, "start_col": 2, "start_line": 297 }
FStar.Pervasives.Lemma
val intersection_idempotent_right_lemma: Prims.unit -> Lemma (intersection_idempotent_right_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2))
val intersection_idempotent_right_lemma: Prims.unit -> Lemma (intersection_idempotent_right_fact) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.intersection", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.intersection_idempotent_right_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intersection_idempotent_right_lemma: Prims.unit -> Lemma (intersection_idempotent_right_fact)
[]
FStar.FiniteSet.Base.intersection_idempotent_right_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.intersection_idempotent_right_fact)
{ "end_col": 79, "end_line": 293, "start_col": 2, "start_line": 292 }
FStar.Pervasives.Lemma
val union_of_disjoint_lemma: Prims.unit -> Lemma (union_of_disjoint_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) )
val union_of_disjoint_lemma: Prims.unit -> Lemma (union_of_disjoint_fact) let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. (assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_imp", "FStar.FiniteSet.Base.disjoint", "Prims.l_and", "Prims.eq2", "FStar.FiniteSet.Base.difference", "FStar.FiniteSet.Base.union", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "Prims.l_True", "FStar.FiniteSet.Base.union_of_disjoint_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_of_disjoint_lemma: Prims.unit -> Lemma (union_of_disjoint_fact)
[]
FStar.FiniteSet.Base.union_of_disjoint_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.union_of_disjoint_fact)
{ "end_col": 5, "end_line": 274, "start_col": 2, "start_line": 268 }
FStar.Pervasives.Lemma
val insert_nonmember_cardinality_lemma: Prims.unit -> Lemma (insert_nonmember_cardinality_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) )
val insert_nonmember_cardinality_lemma: Prims.unit -> Lemma (insert_nonmember_cardinality_fact) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) =
false
null
true
introduce forall (a: eqtype) (s: set a) (x: a) . not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. (reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "Prims.op_Negation", "FStar.FiniteSet.Base.mem", "Prims.op_Equality", "Prims.int", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.insert", "Prims.op_Addition", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.FiniteSet.Base.nonrepeating_lists_with_same_elements_have_same_length", "Prims.Cons", "FStar.FiniteSet.Base.set_as_list", "FStar.Pervasives.reveal_opaque", "Prims.nat", "Prims.l_True", "FStar.FiniteSet.Base.insert_nonmember_cardinality_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val insert_nonmember_cardinality_lemma: Prims.unit -> Lemma (insert_nonmember_cardinality_fact)
[]
FStar.FiniteSet.Base.insert_nonmember_cardinality_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.insert_nonmember_cardinality_fact)
{ "end_col": 5, "end_line": 252, "start_col": 2, "start_line": 246 }
FStar.Pervasives.Lemma
val set_as_list_cardinality_lemma: Prims.unit -> Lemma (set_as_list_cardinality_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set_as_list_cardinality_lemma () : Lemma (set_as_list_cardinality_fact) = introduce forall (a: eqtype) (s: set a). FLT.length (set_as_list s) = cardinality s with reveal_opaque (`%cardinality) (cardinality #a)
val set_as_list_cardinality_lemma: Prims.unit -> Lemma (set_as_list_cardinality_fact) let set_as_list_cardinality_lemma () : Lemma (set_as_list_cardinality_fact) =
false
null
true
introduce forall (a: eqtype) (s: set a) . FLT.length (set_as_list s) = cardinality s with reveal_opaque (`%cardinality) (cardinality #a)
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.List.Tot.Base.length", "FStar.FiniteSet.Base.set_as_list", "FStar.FiniteSet.Base.cardinality", "FStar.Pervasives.reveal_opaque", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.set_as_list_cardinality_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) ) let equal_extensionality_lemma () : Lemma (equal_extensionality_fact) = () let disjoint_lemma () : Lemma (disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. ( introduce forall x. not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2)) ) ) let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) = assert (feq s (insert x (remove x s))) let insert_remove_lemma () : Lemma (insert_remove_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = true ==> insert x (remove x s) == s with introduce mem x s = true ==> insert x (remove x s) == s with _. insert_remove_helper a x s let remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s) = assert (feq s (remove x (insert x s))) let remove_insert_lemma () : Lemma (remove_insert_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = false ==> remove x (insert x s) == s with introduce mem x s = false ==> remove x (insert x s) == s with _. remove_insert_helper a x s let set_as_list_cardinality_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set_as_list_cardinality_lemma: Prims.unit -> Lemma (set_as_list_cardinality_fact)
[]
FStar.FiniteSet.Base.set_as_list_cardinality_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.set_as_list_cardinality_fact)
{ "end_col": 53, "end_line": 436, "start_col": 2, "start_line": 435 }
FStar.Pervasives.Lemma
val insert_remove_lemma: Prims.unit -> Lemma (insert_remove_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let insert_remove_lemma () : Lemma (insert_remove_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = true ==> insert x (remove x s) == s with introduce mem x s = true ==> insert x (remove x s) == s with _. insert_remove_helper a x s
val insert_remove_lemma: Prims.unit -> Lemma (insert_remove_fact) let insert_remove_lemma () : Lemma (insert_remove_fact) =
false
null
true
introduce forall (a: eqtype) (x: a) (s: set a) . mem x s = true ==> insert x (remove x s) == s with introduce mem x s = true ==> insert x (remove x s) == s with _. insert_remove_helper a x s
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.bool", "FStar.FiniteSet.Base.mem", "Prims.eq2", "FStar.FiniteSet.Base.insert", "FStar.FiniteSet.Base.remove", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.FiniteSet.Base.insert_remove_helper", "Prims.l_True", "FStar.FiniteSet.Base.insert_remove_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) ) let equal_extensionality_lemma () : Lemma (equal_extensionality_fact) = () let disjoint_lemma () : Lemma (disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. ( introduce forall x. not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2)) ) ) let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) = assert (feq s (insert x (remove x s))) let insert_remove_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val insert_remove_lemma: Prims.unit -> Lemma (insert_remove_fact)
[]
FStar.FiniteSet.Base.insert_remove_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.insert_remove_fact)
{ "end_col": 39, "end_line": 420, "start_col": 2, "start_line": 417 }
FStar.Pervasives.Lemma
val union_idempotent_left_lemma: Prims.unit -> Lemma (union_idempotent_left_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2))
val union_idempotent_left_lemma: Prims.unit -> Lemma (union_idempotent_left_fact) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.union", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.union_idempotent_left_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_idempotent_left_lemma: Prims.unit -> Lemma (union_idempotent_left_fact)
[]
FStar.FiniteSet.Base.union_idempotent_left_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.union_idempotent_left_fact)
{ "end_col": 58, "end_line": 288, "start_col": 2, "start_line": 287 }
FStar.Pervasives.Lemma
val cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1 s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2))
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2)))
val cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1 s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1 s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) =
false
null
true
union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2)))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "FStar.FiniteSet.Base.union", "FStar.FiniteSet.Base.difference", "FStar.FiniteSet.Base.intersection", "Prims.unit", "FStar.FiniteSet.Base.union_of_disjoint_sets_cardinality_lemma", "Prims.l_True", "Prims.squash", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.FiniteSet.Base.cardinality", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1 s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2))
[]
FStar.FiniteSet.Base.cardinality_matches_difference_plus_intersection_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.cardinality s1 = FStar.FiniteSet.Base.cardinality (FStar.FiniteSet.Base.difference s1 s2) + FStar.FiniteSet.Base.cardinality (FStar.FiniteSet.Base.intersection s1 s2))
{ "end_col": 65, "end_line": 326, "start_col": 2, "start_line": 325 }
FStar.Pervasives.Lemma
val insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) = assert (feq s (insert x (remove x s)))
val insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) =
false
null
true
assert (feq s (insert x (remove x s)))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "FStar.FiniteSet.Base.insert", "FStar.FiniteSet.Base.remove", "Prims.unit", "Prims.b2t", "FStar.FiniteSet.Base.mem", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) ) let equal_extensionality_lemma () : Lemma (equal_extensionality_fact) = () let disjoint_lemma () : Lemma (disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. ( introduce forall x. not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2)) ) ) let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s)
[]
FStar.FiniteSet.Base.insert_remove_helper
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Prims.eqtype -> x: a -> s: FStar.FiniteSet.Base.set a -> FStar.Pervasives.Lemma (requires FStar.FiniteSet.Base.mem x s) (ensures FStar.FiniteSet.Base.insert x (FStar.FiniteSet.Base.remove x s) == s)
{ "end_col": 40, "end_line": 413, "start_col": 2, "start_line": 413 }
FStar.Pervasives.Lemma
val union_is_differences_and_intersection (#a: eqtype) (s1 s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)))
val union_is_differences_and_intersection (#a: eqtype) (s1 s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) let union_is_differences_and_intersection (#a: eqtype) (s1 s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) =
false
null
true
assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) )
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "FStar.FiniteSet.Base.union", "FStar.FiniteSet.Base.difference", "FStar.FiniteSet.Base.intersection", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_is_differences_and_intersection (#a: eqtype) (s1 s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))
[]
FStar.FiniteSet.Base.union_is_differences_and_intersection
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.FiniteSet.Base.set a -> s2: FStar.FiniteSet.Base.set a -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.union s1 s2 == FStar.FiniteSet.Base.union (FStar.FiniteSet.Base.union (FStar.FiniteSet.Base.difference s1 s2) (FStar.FiniteSet.Base.intersection s1 s2)) (FStar.FiniteSet.Base.difference s2 s1))
{ "end_col": 103, "end_line": 330, "start_col": 2, "start_line": 330 }
FStar.Pervasives.Lemma
val union_idempotent_right_lemma: Prims.unit -> Lemma (union_idempotent_right_fact)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2))
val union_idempotent_right_lemma: Prims.unit -> Lemma (union_idempotent_right_fact) let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) =
false
null
true
introduce forall (a: eqtype) (s1: set a) (s2: set a) . union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.eqtype", "Prims.l_Forall", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.union", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "Prims.squash", "Prims.l_True", "FStar.FiniteSet.Base.union_idempotent_right_fact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma ()
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val union_idempotent_right_lemma: Prims.unit -> Lemma (union_idempotent_right_fact)
[]
FStar.FiniteSet.Base.union_idempotent_right_lemma
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures FStar.FiniteSet.Base.union_idempotent_right_fact)
{ "end_col": 58, "end_line": 283, "start_col": 2, "start_line": 282 }
FStar.Pervasives.Lemma
val remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s)
[ { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s) = assert (feq s (remove x (insert x s)))
val remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s) let remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s) =
false
null
true
assert (feq s (remove x (insert x s)))
{ "checked_file": "FStar.FiniteSet.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.Sugar.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.FiniteSet.Base.fst" }
[ "lemma" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.bool", "FStar.FiniteSet.Base.remove", "FStar.FiniteSet.Base.insert", "Prims.unit", "Prims.b2t", "Prims.op_Equality", "FStar.FiniteSet.Base.mem", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base module FLT = FStar.List.Tot open FStar.FunctionalExtensionality let has_elements (#a: eqtype) (f: a ^-> bool) (xs: list a): prop = forall x. f x == x `FLT.mem` xs // Finite sets type set (a: eqtype) = f:(a ^-> bool){exists xs. f `has_elements` xs} /// We represent the Dafny function [] on sets with `mem`: let mem (#a: eqtype) (x: a) (s: set a) : bool = s x /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; let rec remove_repeats (#a: eqtype) (xs: list a) : (ys: list a{list_nonrepeating ys /\ (forall y. FLT.mem y ys <==> FLT.mem y xs)}) = match xs with | [] -> [] | hd :: tl -> let tl' = remove_repeats tl in if FLT.mem hd tl then tl' else hd :: tl' let set_as_list (#a: eqtype) (s: set a): GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) = remove_repeats (FStar.IndefiniteDescription.indefinite_description_ghost (list a) (fun xs -> forall x. FLT.mem x xs = mem x s)) [@"opaque_to_smt"] let cardinality (#a: eqtype) (s: set a) : GTot nat = FLT.length (set_as_list s) let intro_set (#a: eqtype) (f: a ^-> bool) (xs: Ghost.erased (list a)) : Pure (set a) (requires f `has_elements` xs) (ensures fun _ -> True) = Classical.exists_intro (fun xs -> f `has_elements` xs) xs; f /// We represent the Dafny function `Set#Empty` with `empty`: let emptyset (#a: eqtype): set a = intro_set (on_dom a (fun _ -> false)) [] /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; let insert (#a: eqtype) (x: a) (s: set a): set a = intro_set (on_dom _ (fun x' -> x = x' || s x')) (x :: set_as_list s) /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; let singleton (#a: eqtype) (x: a) : set a = insert x emptyset /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; let rec union_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs \/ FLT.mem z ys}) = match xs with | [] -> ys | hd :: tl -> hd :: union_lists tl ys let union (#a: eqtype) (s1: set a) (s2: set a) : (set a) = intro_set (on_dom a (fun x -> s1 x || s2 x)) (union_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; let rec intersect_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ FLT.mem z ys}) = match xs with | [] -> [] | hd :: tl -> let zs' = intersect_lists tl ys in if FLT.mem hd ys then hd :: zs' else zs' let intersection (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && s2 x)) (intersect_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; let rec difference_lists (#a: eqtype) (xs: list a) (ys: list a) : (zs: list a{forall z. FLT.mem z zs <==> FLT.mem z xs /\ ~(FLT.mem z ys)}) = match xs with | [] -> [] | hd :: tl -> let zs' = difference_lists tl ys in if FLT.mem hd ys then zs' else hd :: zs' let difference (#a: eqtype) (s1: set a) (s2: set a) : set a = intro_set (on_dom a (fun x -> s1 x && not (s2 x))) (difference_lists (set_as_list s1) (set_as_list s2)) /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; let subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. (s1 x = true) ==> (s2 x = true) /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; let equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 = feq s1 s2 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; let disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 = forall x. not (s1 x && s2 x) /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; let choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) = Cons?.hd (set_as_list s) /// We now prove each of the facts that comprise `all_finite_set_facts`. /// For fact `xxx_fact`, we prove it with `xxx_lemma`. Sometimes, that /// requires a helper lemma, which we call `xxx_helper`. let empty_set_contains_no_elements_lemma () : Lemma (empty_set_contains_no_elements_fact) = () let length_zero_lemma () : Lemma (length_zero_fact) = introduce forall (a: eqtype) (s: set a). (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) with ( reveal_opaque (`%cardinality) (cardinality #a); introduce cardinality s = 0 ==> s == emptyset with _. assert (feq s emptyset); introduce s == emptyset ==> cardinality s = 0 with _. assert (set_as_list s == []); introduce cardinality s <> 0 ==> _ with _. introduce exists x. mem x s with (Cons?.hd (set_as_list s)) and ()) let singleton_contains_argument_lemma () : Lemma (singleton_contains_argument_fact) = () let singleton_contains_lemma () : Lemma (singleton_contains_fact) = () let rec singleton_cardinality_helper (#a: eqtype) (r: a) (xs: list a) : Lemma (requires FLT.mem r xs /\ (forall x. FLT.mem x xs <==> x = r)) (ensures remove_repeats xs == [r]) = match xs with | [x] -> () | hd :: tl -> assert (Cons?.hd tl = r); singleton_cardinality_helper r tl let singleton_cardinality_lemma () : Lemma (singleton_cardinality_fact) = introduce forall (a: eqtype) (r: a). cardinality (singleton r) = 1 with ( reveal_opaque (`%cardinality) (cardinality #a); singleton_cardinality_helper r (set_as_list (singleton r)) ) let insert_lemma () : Lemma (insert_fact) = () let insert_contains_argument_lemma () : Lemma (insert_contains_argument_fact) = () let insert_contains_lemma () : Lemma (insert_contains_fact) = () let rec remove_from_nonrepeating_list (#a: eqtype) (x: a) (xs: list a{FLT.mem x xs /\ list_nonrepeating xs}) : (xs': list a{ list_nonrepeating xs' /\ FLT.length xs' = FLT.length xs - 1 /\ (forall y. FLT.mem y xs' <==> FLT.mem y xs /\ y <> x)}) = match xs with | hd :: tl -> if x = hd then tl else hd :: (remove_from_nonrepeating_list x tl) let rec nonrepeating_lists_with_same_elements_have_same_length (#a: eqtype) (s1: list a) (s2: list a) : Lemma (requires list_nonrepeating s1 /\ list_nonrepeating s2 /\ (forall x. FLT.mem x s1 <==> FLT.mem x s2)) (ensures FLT.length s1 = FLT.length s2) = match s1 with | [] -> () | hd :: tl -> nonrepeating_lists_with_same_elements_have_same_length tl (remove_from_nonrepeating_list hd s2) let insert_member_cardinality_lemma () : Lemma (insert_member_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). mem x s ==> cardinality (insert x s) = cardinality s with introduce mem x s ==> cardinality (insert x s) = cardinality s with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (set_as_list s) (set_as_list (insert x s)) ) let insert_nonmember_cardinality_lemma () : Lemma (insert_nonmember_cardinality_fact) = introduce forall (a: eqtype) (s: set a) (x: a). not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with introduce not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 with _. ( reveal_opaque (`%cardinality) (cardinality #a); nonrepeating_lists_with_same_elements_have_same_length (x :: (set_as_list s)) (set_as_list (insert x s)) ) let union_contains_lemma () : Lemma (union_contains_fact) = () let union_contains_element_from_first_argument_lemma () : Lemma (union_contains_element_from_first_argument_fact) = () let union_contains_element_from_second_argument_lemma () : Lemma (union_contains_element_from_second_argument_fact) = () let union_of_disjoint_lemma () : Lemma (union_of_disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with introduce disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 with _. ( assert (feq (difference (union s1 s2) s1) s2); assert (feq (difference (union s1 s2) s2) s1) ) let intersection_contains_lemma () : Lemma (intersection_contains_fact) = () let union_idempotent_right_lemma () : Lemma (union_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union (union s1 s2) s2 == union s1 s2 with assert (feq (union (union s1 s2) s2) (union s1 s2)) let union_idempotent_left_lemma () : Lemma (union_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). union s1 (union s1 s2) == union s1 s2 with assert (feq (union s1 (union s1 s2)) (union s1 s2)) let intersection_idempotent_right_lemma () : Lemma (intersection_idempotent_right_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection (intersection s1 s2) s2 == intersection s1 s2 with assert (feq (intersection (intersection s1 s2) s2) (intersection s1 s2)) let intersection_idempotent_left_lemma () : Lemma (intersection_idempotent_left_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). intersection s1 (intersection s1 s2) == intersection s1 s2 with assert (feq (intersection s1 (intersection s1 s2)) (intersection s1 s2)) let rec union_of_disjoint_nonrepeating_lists_length_lemma (#a: eqtype) (xs1: list a) (xs2: list a) (xs3: list a) : Lemma (requires list_nonrepeating xs1 /\ list_nonrepeating xs2 /\ list_nonrepeating xs3 /\ (forall x. ~(FLT.mem x xs1 /\ FLT.mem x xs2)) /\ (forall x. FLT.mem x xs3 <==> FLT.mem x xs1 \/ FLT.mem x xs2)) (ensures FLT.length xs3 = FLT.length xs1 + FLT.length xs2) = match xs1 with | [] -> nonrepeating_lists_with_same_elements_have_same_length xs2 xs3 | hd :: tl -> union_of_disjoint_nonrepeating_lists_length_lemma tl xs2 (remove_from_nonrepeating_list hd xs3) let union_of_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (requires disjoint s1 s2) (ensures cardinality (union s1 s2) = cardinality s1 + cardinality s2) = reveal_opaque (`%cardinality) (cardinality #a); union_of_disjoint_nonrepeating_lists_length_lemma (set_as_list s1) (set_as_list s2) (set_as_list (union s1 s2)) let union_of_three_disjoint_sets_cardinality_lemma (#a: eqtype) (s1: set a) (s2: set a) (s3: set a) : Lemma (requires disjoint s1 s2 /\ disjoint s2 s3 /\ disjoint s1 s3) (ensures cardinality (union (union s1 s2) s3) = cardinality s1 + cardinality s2 + cardinality s3) = union_of_disjoint_sets_cardinality_lemma s1 s2; union_of_disjoint_sets_cardinality_lemma (union s1 s2) s3 let cardinality_matches_difference_plus_intersection_lemma (#a: eqtype) (s1: set a) (s2: set a) : Lemma (ensures cardinality s1 = cardinality (difference s1 s2) + cardinality (intersection s1 s2)) = union_of_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2); assert (feq s1 (union (difference s1 s2) (intersection s1 s2))) let union_is_differences_and_intersection (#a: eqtype) (s1: set a) (s2: set a) : Lemma (union s1 s2 == union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1)) = assert (feq (union s1 s2) (union (union (difference s1 s2) (intersection s1 s2)) (difference s2 s1))) let intersection_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2) = cardinality_matches_difference_plus_intersection_lemma s1 s2; cardinality_matches_difference_plus_intersection_lemma s2 s1; union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); assert (feq (intersection s1 s2) (intersection s2 s1)) let intersection_cardinality_lemma () : Lemma (intersection_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 with intersection_cardinality_helper a s1 s2 let difference_contains_lemma () : Lemma (difference_contains_fact) = () let difference_doesnt_include_lemma () : Lemma (difference_doesnt_include_fact) = () let difference_cardinality_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma ( cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)) = union_is_differences_and_intersection s1 s2; union_of_three_disjoint_sets_cardinality_lemma (difference s1 s2) (intersection s1 s2) (difference s2 s1); cardinality_matches_difference_plus_intersection_lemma s1 s2 let difference_cardinality_lemma () : Lemma (difference_cardinality_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) with difference_cardinality_helper a s1 s2 let subset_helper (a: eqtype) (s1: set a) (s2: set a) : Lemma (subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)) = introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) ==> subset s1 s2 with _. introduce forall x. s1 x = true ==> s2 x = true with assert (mem x s1 = s1 x) let subset_lemma () : Lemma (subset_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) with subset_helper a s1 s2 let equal_lemma () : Lemma (equal_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) ==> equal s1 s2 with _. introduce forall x. s1 x = true <==> s2 x = true with assert (mem x s1 = s1 x /\ mem x s2 = s2 x) ) let equal_extensionality_lemma () : Lemma (equal_extensionality_fact) = () let disjoint_lemma () : Lemma (disjoint_fact) = introduce forall (a: eqtype) (s1: set a) (s2: set a). disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) with ( introduce (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) ==> disjoint s1 s2 with _. ( introduce forall x. not (s1 x && s2 x) with assert (not (mem x s1) \/ not (mem x s2)) ) ) let insert_remove_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s) (ensures insert x (remove x s) == s) = assert (feq s (insert x (remove x s))) let insert_remove_lemma () : Lemma (insert_remove_fact) = introduce forall (a: eqtype) (x: a) (s: set a). mem x s = true ==> insert x (remove x s) == s with introduce mem x s = true ==> insert x (remove x s) == s with _. insert_remove_helper a x s let remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false)
false
false
FStar.FiniteSet.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val remove_insert_helper (a: eqtype) (x: a) (s: set a) : Lemma (requires mem x s = false) (ensures remove x (insert x s) == s)
[]
FStar.FiniteSet.Base.remove_insert_helper
{ "file_name": "ulib/FStar.FiniteSet.Base.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Prims.eqtype -> x: a -> s: FStar.FiniteSet.Base.set a -> FStar.Pervasives.Lemma (requires FStar.FiniteSet.Base.mem x s = false) (ensures FStar.FiniteSet.Base.remove x (FStar.FiniteSet.Base.insert x s) == s)
{ "end_col": 40, "end_line": 425, "start_col": 2, "start_line": 425 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pow2_24 = 0x1000000
let pow2_24 =
false
null
false
0x1000000
{ "checked_file": "Vale.AES.GCTR.fst.checked", "dependencies": [ "Vale.Poly1305.Bitvectors.fsti.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR.fst" }
[ "total" ]
[]
[]
module Vale.AES.GCTR open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers #set-options "--z3rlimit 20 --max_fuel 1 --max_ifuel 0" let lemma_counter_init x low64 low8 = Vale.Poly1305.Bitvectors.lemma_bytes_and_mod1 low64; Vale.Def.TypesNative_s.reveal_iand 64 low64 0xff; assert (low8 == low64 % 256); lo64_reveal (); assert_norm (pow2_norm 32 == pow2_32); // OBSERVE assert (low64 == x.lo0 + x.lo1 * pow2_32); // OBSERVE assert (low64 % 256 == x.lo0 % 256); () let gctr_encrypt_block_offset (icb_BE:quad32) (plain_LE:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_encrypt_empty (icb_BE:quad32) (plain_LE cipher_LE:seq quad32) (alg:algorithm) (key:seq nat32) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let plain = slice (le_seq_quad32_to_bytes plain_LE) 0 0 in let cipher = slice (le_seq_quad32_to_bytes cipher_LE) 0 0 in assert (plain == empty); assert (cipher == empty); assert (length plain == 0); assert (make_gctr_plain_LE plain == empty); let num_extra = (length (make_gctr_plain_LE plain)) % 16 in assert (num_extra == 0); let plain_quads_LE = le_bytes_to_seq_quad32 plain in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in assert (equal plain_quads_LE empty); // OBSERVE assert (plain_quads_LE == empty); assert (cipher_quads_LE == empty); assert (equal (le_seq_quad32_to_bytes cipher_quads_LE) empty); // OBSERVEs () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let gctr_partial_extend6 (alg:algorithm) (bound:nat) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_partial_reveal (); () (* let rec seq_map_i_indexed' (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases (length s)) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let rec test (icb_BE:quad32) (plain_LE:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (ensures (let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in gctr_encrypt_recursive icb_BE plain_LE alg key i == seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i)) (decreases (length plain_LE)) = let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in let g = gctr_encrypt_recursive icb_BE plain_LE alg key i in let s = seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i in if length plain_LE = 0 then ( assert(equal (g) (s)); () ) else ( test icb_BE (tail plain_LE) alg key (i+1); assert (gctr_encrypt_recursive icb_BE (tail plain_LE) alg key (i+1) == seq_map_i_indexed' gctr_encrypt_block_curried (tail plain_LE) (i+1)) ) *) let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb_BE:quad32) (plain:gctr_plain_LE) (alg:algorithm) (key:aes_key_LE alg) : Lemma(length (gctr_encrypt_LE icb_BE plain alg key) == length plain) [SMTPat (length (gctr_encrypt_LE icb_BE plain alg key))] = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt_LE icb_BE plain alg key in if num_extra = 0 then ( let plain_quads_LE = le_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb_BE plain_quads_LE alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let final_quad_LE = le_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_LE = gctr_encrypt_recursive icb_BE full_quads_LE alg key 0 in let final_cipher_quad_LE = gctr_encrypt_block icb_BE final_quad_LE alg key (full_bytes_len / 16) in let cipher_bytes_full_LE = le_seq_quad32_to_bytes cipher_quads_LE in let final_cipher_bytes_LE = slice (le_quad32_to_bytes final_cipher_quad_LE) 0 num_extra in gctr_encrypt_recursive_length icb_BE full_quads_LE alg key 0; assert (length result == length cipher_bytes_full_LE + length final_cipher_bytes_LE); assert (length cipher_quads_LE == length full_quads_LE); assert (length cipher_bytes_full_LE == 16 * length cipher_quads_LE); assert (16 * length full_quads_LE == length full_blocks); assert (length cipher_bytes_full_LE == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_BE alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_BE alg key (inc32 icb (i + j)) ))) = aes_encrypt_LE_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_BE alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_BE alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_LE alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb_BE:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_LE_reveal (); let p = le_seq_quad32_to_bytes plain in assert (length p % 16 == 0); let plain_quads_LE = le_bytes_to_seq_quad32 p in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in let cipher_bytes = le_seq_quad32_to_bytes cipher_quads_LE in le_bytes_to_seq_quad32_to_bytes plain; () (* Want to show that: slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, out_b))) 0 num_bytes == gctr_encrypt_LE icb_BE (slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, in_b))) 0 num_bytes) ... We know that slice (buffer128_as_seq(mem, out_b) 0 num_blocks == gctr_encrypt_recursive icb_BE (slice buffer128_as_seq(mem, in_b) 0 num_blocks) ... And we know that: get_mem out_b num_blocks == gctr_encrypt_block(icb_BE, (get_mem inb num_blocks), alg, key, num_blocks); Internally gctr_encrypt_LE will compute: full_blocks, final_block = split (slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, in_b))) 0 num_bytes) (num_blocks * 16) We'd like to show that Step1: le_bytes_to_seq_quad32 full_blocks == slice buffer128_as_seq(mem, in_b) 0 num_blocks and Step2: final_block == slice (le_quad32_to_bytes (get_mem inb num_blocks)) 0 num_extra Then we need to break down the byte-level effects of gctr_encrypt_block to show that even though the padded version of final_block differs from (get_mem inb num_blocks), after we slice it at the end, we end up with the same value *) let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (le_seq_quad32_to_bytes p) 0 num_bytes) (num_blocks * 16) in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_LE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (le_seq_quad32_to_bytes p) 0 num_bytes) (num_blocks * 16) in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (le_seq_quad32_to_bytes p) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (le_seq_quad32_to_bytes p) 0 (num_blocks * 16)); slice_commutes_le_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == le_seq_quad32_to_bytes (slice p 0 num_blocks)); le_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_LE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishl_32 (x:nat32) (k:nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32) = Vale.Def.TypesNative_s.reveal_ishl 32 x k; FStar.UInt.shift_left_value_lemma #32 x k; () let lemma_ishl_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishl #pow2_32 (ixor x y) k == ixor (ishl x k) (ishl y k)) = Vale.Def.TypesNative_s.reveal_ishl 32 x k; Vale.Def.TypesNative_s.reveal_ishl 32 y k; Vale.Def.TypesNative_s.reveal_ishl 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishl x k) (ishl y k); FStar.UInt.shift_left_logxor_lemma #32 x y k; ()
false
true
Vale.AES.GCTR.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow2_24 : Prims.int
[]
Vale.AES.GCTR.pow2_24
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 30, "end_line": 296, "start_col": 21, "start_line": 296 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nat24 = natN pow2_24
let nat24 =
false
null
false
natN pow2_24
{ "checked_file": "Vale.AES.GCTR.fst.checked", "dependencies": [ "Vale.Poly1305.Bitvectors.fsti.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR.fst" }
[ "total" ]
[ "Vale.Def.Words_s.natN", "Vale.AES.GCTR.pow2_24" ]
[]
module Vale.AES.GCTR open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers #set-options "--z3rlimit 20 --max_fuel 1 --max_ifuel 0" let lemma_counter_init x low64 low8 = Vale.Poly1305.Bitvectors.lemma_bytes_and_mod1 low64; Vale.Def.TypesNative_s.reveal_iand 64 low64 0xff; assert (low8 == low64 % 256); lo64_reveal (); assert_norm (pow2_norm 32 == pow2_32); // OBSERVE assert (low64 == x.lo0 + x.lo1 * pow2_32); // OBSERVE assert (low64 % 256 == x.lo0 % 256); () let gctr_encrypt_block_offset (icb_BE:quad32) (plain_LE:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_encrypt_empty (icb_BE:quad32) (plain_LE cipher_LE:seq quad32) (alg:algorithm) (key:seq nat32) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let plain = slice (le_seq_quad32_to_bytes plain_LE) 0 0 in let cipher = slice (le_seq_quad32_to_bytes cipher_LE) 0 0 in assert (plain == empty); assert (cipher == empty); assert (length plain == 0); assert (make_gctr_plain_LE plain == empty); let num_extra = (length (make_gctr_plain_LE plain)) % 16 in assert (num_extra == 0); let plain_quads_LE = le_bytes_to_seq_quad32 plain in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in assert (equal plain_quads_LE empty); // OBSERVE assert (plain_quads_LE == empty); assert (cipher_quads_LE == empty); assert (equal (le_seq_quad32_to_bytes cipher_quads_LE) empty); // OBSERVEs () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let gctr_partial_extend6 (alg:algorithm) (bound:nat) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_partial_reveal (); () (* let rec seq_map_i_indexed' (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases (length s)) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let rec test (icb_BE:quad32) (plain_LE:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (ensures (let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in gctr_encrypt_recursive icb_BE plain_LE alg key i == seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i)) (decreases (length plain_LE)) = let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in let g = gctr_encrypt_recursive icb_BE plain_LE alg key i in let s = seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i in if length plain_LE = 0 then ( assert(equal (g) (s)); () ) else ( test icb_BE (tail plain_LE) alg key (i+1); assert (gctr_encrypt_recursive icb_BE (tail plain_LE) alg key (i+1) == seq_map_i_indexed' gctr_encrypt_block_curried (tail plain_LE) (i+1)) ) *) let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb_BE:quad32) (plain:gctr_plain_LE) (alg:algorithm) (key:aes_key_LE alg) : Lemma(length (gctr_encrypt_LE icb_BE plain alg key) == length plain) [SMTPat (length (gctr_encrypt_LE icb_BE plain alg key))] = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt_LE icb_BE plain alg key in if num_extra = 0 then ( let plain_quads_LE = le_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb_BE plain_quads_LE alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let final_quad_LE = le_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_LE = gctr_encrypt_recursive icb_BE full_quads_LE alg key 0 in let final_cipher_quad_LE = gctr_encrypt_block icb_BE final_quad_LE alg key (full_bytes_len / 16) in let cipher_bytes_full_LE = le_seq_quad32_to_bytes cipher_quads_LE in let final_cipher_bytes_LE = slice (le_quad32_to_bytes final_cipher_quad_LE) 0 num_extra in gctr_encrypt_recursive_length icb_BE full_quads_LE alg key 0; assert (length result == length cipher_bytes_full_LE + length final_cipher_bytes_LE); assert (length cipher_quads_LE == length full_quads_LE); assert (length cipher_bytes_full_LE == 16 * length cipher_quads_LE); assert (16 * length full_quads_LE == length full_blocks); assert (length cipher_bytes_full_LE == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_BE alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_BE alg key (inc32 icb (i + j)) ))) = aes_encrypt_LE_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_BE alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_BE alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_LE alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb_BE:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_LE_reveal (); let p = le_seq_quad32_to_bytes plain in assert (length p % 16 == 0); let plain_quads_LE = le_bytes_to_seq_quad32 p in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in let cipher_bytes = le_seq_quad32_to_bytes cipher_quads_LE in le_bytes_to_seq_quad32_to_bytes plain; () (* Want to show that: slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, out_b))) 0 num_bytes == gctr_encrypt_LE icb_BE (slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, in_b))) 0 num_bytes) ... We know that slice (buffer128_as_seq(mem, out_b) 0 num_blocks == gctr_encrypt_recursive icb_BE (slice buffer128_as_seq(mem, in_b) 0 num_blocks) ... And we know that: get_mem out_b num_blocks == gctr_encrypt_block(icb_BE, (get_mem inb num_blocks), alg, key, num_blocks); Internally gctr_encrypt_LE will compute: full_blocks, final_block = split (slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, in_b))) 0 num_bytes) (num_blocks * 16) We'd like to show that Step1: le_bytes_to_seq_quad32 full_blocks == slice buffer128_as_seq(mem, in_b) 0 num_blocks and Step2: final_block == slice (le_quad32_to_bytes (get_mem inb num_blocks)) 0 num_extra Then we need to break down the byte-level effects of gctr_encrypt_block to show that even though the padded version of final_block differs from (get_mem inb num_blocks), after we slice it at the end, we end up with the same value *) let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (le_seq_quad32_to_bytes p) 0 num_bytes) (num_blocks * 16) in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_LE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (le_seq_quad32_to_bytes p) 0 num_bytes) (num_blocks * 16) in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (le_seq_quad32_to_bytes p) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (le_seq_quad32_to_bytes p) 0 (num_blocks * 16)); slice_commutes_le_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == le_seq_quad32_to_bytes (slice p 0 num_blocks)); le_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_LE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishl_32 (x:nat32) (k:nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32) = Vale.Def.TypesNative_s.reveal_ishl 32 x k; FStar.UInt.shift_left_value_lemma #32 x k; () let lemma_ishl_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishl #pow2_32 (ixor x y) k == ixor (ishl x k) (ishl y k)) = Vale.Def.TypesNative_s.reveal_ishl 32 x k; Vale.Def.TypesNative_s.reveal_ishl 32 y k; Vale.Def.TypesNative_s.reveal_ishl 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishl x k) (ishl y k); FStar.UInt.shift_left_logxor_lemma #32 x y k; ()
false
true
Vale.AES.GCTR.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat24 : Type0
[]
Vale.AES.GCTR.nat24
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 24, "end_line": 297, "start_col": 12, "start_line": 297 }
FStar.Pervasives.Lemma
val gctr_partial_opaque_init (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_LE alg key) (ensures gctr_partial alg 0 plain cipher key icb)
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); ()
val gctr_partial_opaque_init (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_LE alg key) (ensures gctr_partial alg 0 plain cipher key icb) let gctr_partial_opaque_init alg plain cipher key icb =
false
null
true
gctr_partial_reveal (); ()
{ "checked_file": "Vale.AES.GCTR.fst.checked", "dependencies": [ "Vale.Poly1305.Bitvectors.fsti.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR.fst" }
[ "lemma" ]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.AES.GCTR.gctr_partial_reveal" ]
[]
module Vale.AES.GCTR open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers #set-options "--z3rlimit 20 --max_fuel 1 --max_ifuel 0" let lemma_counter_init x low64 low8 = Vale.Poly1305.Bitvectors.lemma_bytes_and_mod1 low64; Vale.Def.TypesNative_s.reveal_iand 64 low64 0xff; assert (low8 == low64 % 256); lo64_reveal (); assert_norm (pow2_norm 32 == pow2_32); // OBSERVE assert (low64 == x.lo0 + x.lo1 * pow2_32); // OBSERVE assert (low64 % 256 == x.lo0 % 256); () let gctr_encrypt_block_offset (icb_BE:quad32) (plain_LE:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_encrypt_empty (icb_BE:quad32) (plain_LE cipher_LE:seq quad32) (alg:algorithm) (key:seq nat32) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let plain = slice (le_seq_quad32_to_bytes plain_LE) 0 0 in let cipher = slice (le_seq_quad32_to_bytes cipher_LE) 0 0 in assert (plain == empty); assert (cipher == empty); assert (length plain == 0); assert (make_gctr_plain_LE plain == empty); let num_extra = (length (make_gctr_plain_LE plain)) % 16 in assert (num_extra == 0); let plain_quads_LE = le_bytes_to_seq_quad32 plain in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in assert (equal plain_quads_LE empty); // OBSERVE assert (plain_quads_LE == empty); assert (cipher_quads_LE == empty); assert (equal (le_seq_quad32_to_bytes cipher_quads_LE) empty); // OBSERVEs ()
false
false
Vale.AES.GCTR.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gctr_partial_opaque_init (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_LE alg key) (ensures gctr_partial alg 0 plain cipher key icb)
[]
Vale.AES.GCTR.gctr_partial_opaque_init
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_s.is_aes_key_LE alg key) (ensures Vale.AES.GCTR.gctr_partial alg 0 plain cipher key icb)
{ "end_col": 4, "end_line": 54, "start_col": 2, "start_line": 53 }
FStar.Pervasives.Lemma
val gctr_encrypt_recursive_length (icb: quad32) (plain: gctr_plain_internal_LE) (alg: algorithm) (key: aes_key_LE alg) (i: int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))]
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1)
val gctr_encrypt_recursive_length (icb: quad32) (plain: gctr_plain_internal_LE) (alg: algorithm) (key: aes_key_LE alg) (i: int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] let rec gctr_encrypt_recursive_length (icb: quad32) (plain: gctr_plain_internal_LE) (alg: algorithm) (key: aes_key_LE alg) (i: int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] =
false
null
true
if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1)
{ "checked_file": "Vale.AES.GCTR.fst.checked", "dependencies": [ "Vale.Poly1305.Bitvectors.fsti.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR.fst" }
[ "lemma", "" ]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_s.gctr_plain_internal_LE", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_s.aes_key_LE", "Prims.int", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.bool", "Vale.AES.GCTR.gctr_encrypt_recursive_length", "FStar.Seq.Properties.tail", "Prims.op_Addition", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.nat", "Vale.AES.GCTR_s.gctr_encrypt_recursive", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Vale.AES.GCTR open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers #set-options "--z3rlimit 20 --max_fuel 1 --max_ifuel 0" let lemma_counter_init x low64 low8 = Vale.Poly1305.Bitvectors.lemma_bytes_and_mod1 low64; Vale.Def.TypesNative_s.reveal_iand 64 low64 0xff; assert (low8 == low64 % 256); lo64_reveal (); assert_norm (pow2_norm 32 == pow2_32); // OBSERVE assert (low64 == x.lo0 + x.lo1 * pow2_32); // OBSERVE assert (low64 % 256 == x.lo0 % 256); () let gctr_encrypt_block_offset (icb_BE:quad32) (plain_LE:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_encrypt_empty (icb_BE:quad32) (plain_LE cipher_LE:seq quad32) (alg:algorithm) (key:seq nat32) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let plain = slice (le_seq_quad32_to_bytes plain_LE) 0 0 in let cipher = slice (le_seq_quad32_to_bytes cipher_LE) 0 0 in assert (plain == empty); assert (cipher == empty); assert (length plain == 0); assert (make_gctr_plain_LE plain == empty); let num_extra = (length (make_gctr_plain_LE plain)) % 16 in assert (num_extra == 0); let plain_quads_LE = le_bytes_to_seq_quad32 plain in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in assert (equal plain_quads_LE empty); // OBSERVE assert (plain_quads_LE == empty); assert (cipher_quads_LE == empty); assert (equal (le_seq_quad32_to_bytes cipher_quads_LE) empty); // OBSERVEs () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let gctr_partial_extend6 (alg:algorithm) (bound:nat) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_partial_reveal (); () (* let rec seq_map_i_indexed' (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases (length s)) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let rec test (icb_BE:quad32) (plain_LE:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (ensures (let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in gctr_encrypt_recursive icb_BE plain_LE alg key i == seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i)) (decreases (length plain_LE)) = let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in let g = gctr_encrypt_recursive icb_BE plain_LE alg key i in let s = seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i in if length plain_LE = 0 then ( assert(equal (g) (s)); () ) else ( test icb_BE (tail plain_LE) alg key (i+1); assert (gctr_encrypt_recursive icb_BE (tail plain_LE) alg key (i+1) == seq_map_i_indexed' gctr_encrypt_block_curried (tail plain_LE) (i+1)) ) *) let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))]
false
false
Vale.AES.GCTR.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gctr_encrypt_recursive_length (icb: quad32) (plain: gctr_plain_internal_LE) (alg: algorithm) (key: aes_key_LE alg) (i: int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))]
[ "recursion" ]
Vale.AES.GCTR.gctr_encrypt_recursive_length
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_s.gctr_plain_internal_LE -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_s.aes_key_LE alg -> i: Prims.int -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.length (Vale.AES.GCTR_s.gctr_encrypt_recursive icb plain alg key i) == FStar.Seq.Base.length plain) (decreases FStar.Seq.Base.length plain) [SMTPat (FStar.Seq.Base.length (Vale.AES.GCTR_s.gctr_encrypt_recursive icb plain alg key i))]
{ "end_col": 69, "end_line": 113, "start_col": 2, "start_line": 112 }
FStar.Pervasives.Lemma
val lemma_ishl_32 (x: nat32) (k: nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32)
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_ishl_32 (x:nat32) (k:nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32) = Vale.Def.TypesNative_s.reveal_ishl 32 x k; FStar.UInt.shift_left_value_lemma #32 x k; ()
val lemma_ishl_32 (x: nat32) (k: nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32) let lemma_ishl_32 (x: nat32) (k: nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32) =
false
null
true
Vale.Def.TypesNative_s.reveal_ishl 32 x k; FStar.UInt.shift_left_value_lemma #32 x k; ()
{ "checked_file": "Vale.AES.GCTR.fst.checked", "dependencies": [ "Vale.Poly1305.Bitvectors.fsti.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.nat32", "Prims.nat", "Prims.unit", "FStar.UInt.shift_left_value_lemma", "Vale.Def.TypesNative_s.reveal_ishl", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.int", "Vale.Def.Types_s.ishl", "Vale.Def.Words_s.pow2_32", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.pow2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.GCTR open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers #set-options "--z3rlimit 20 --max_fuel 1 --max_ifuel 0" let lemma_counter_init x low64 low8 = Vale.Poly1305.Bitvectors.lemma_bytes_and_mod1 low64; Vale.Def.TypesNative_s.reveal_iand 64 low64 0xff; assert (low8 == low64 % 256); lo64_reveal (); assert_norm (pow2_norm 32 == pow2_32); // OBSERVE assert (low64 == x.lo0 + x.lo1 * pow2_32); // OBSERVE assert (low64 % 256 == x.lo0 % 256); () let gctr_encrypt_block_offset (icb_BE:quad32) (plain_LE:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_encrypt_empty (icb_BE:quad32) (plain_LE cipher_LE:seq quad32) (alg:algorithm) (key:seq nat32) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let plain = slice (le_seq_quad32_to_bytes plain_LE) 0 0 in let cipher = slice (le_seq_quad32_to_bytes cipher_LE) 0 0 in assert (plain == empty); assert (cipher == empty); assert (length plain == 0); assert (make_gctr_plain_LE plain == empty); let num_extra = (length (make_gctr_plain_LE plain)) % 16 in assert (num_extra == 0); let plain_quads_LE = le_bytes_to_seq_quad32 plain in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in assert (equal plain_quads_LE empty); // OBSERVE assert (plain_quads_LE == empty); assert (cipher_quads_LE == empty); assert (equal (le_seq_quad32_to_bytes cipher_quads_LE) empty); // OBSERVEs () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let gctr_partial_extend6 (alg:algorithm) (bound:nat) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_partial_reveal (); () (* let rec seq_map_i_indexed' (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases (length s)) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let rec test (icb_BE:quad32) (plain_LE:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (ensures (let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in gctr_encrypt_recursive icb_BE plain_LE alg key i == seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i)) (decreases (length plain_LE)) = let gctr_encrypt_block_curried (j:int) (p:quad32) = gctr_encrypt_block icb_BE p alg key j in let g = gctr_encrypt_recursive icb_BE plain_LE alg key i in let s = seq_map_i_indexed' gctr_encrypt_block_curried plain_LE i in if length plain_LE = 0 then ( assert(equal (g) (s)); () ) else ( test icb_BE (tail plain_LE) alg key (i+1); assert (gctr_encrypt_recursive icb_BE (tail plain_LE) alg key (i+1) == seq_map_i_indexed' gctr_encrypt_block_curried (tail plain_LE) (i+1)) ) *) let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb_BE:quad32) (plain:gctr_plain_LE) (alg:algorithm) (key:aes_key_LE alg) : Lemma(length (gctr_encrypt_LE icb_BE plain alg key) == length plain) [SMTPat (length (gctr_encrypt_LE icb_BE plain alg key))] = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; gctr_encrypt_LE_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt_LE icb_BE plain alg key in if num_extra = 0 then ( let plain_quads_LE = le_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb_BE plain_quads_LE alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let final_quad_LE = le_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_LE = gctr_encrypt_recursive icb_BE full_quads_LE alg key 0 in let final_cipher_quad_LE = gctr_encrypt_block icb_BE final_quad_LE alg key (full_bytes_len / 16) in let cipher_bytes_full_LE = le_seq_quad32_to_bytes cipher_quads_LE in let final_cipher_bytes_LE = slice (le_quad32_to_bytes final_cipher_quad_LE) 0 num_extra in gctr_encrypt_recursive_length icb_BE full_quads_LE alg key 0; assert (length result == length cipher_bytes_full_LE + length final_cipher_bytes_LE); assert (length cipher_quads_LE == length full_quads_LE); assert (length cipher_bytes_full_LE == 16 * length cipher_quads_LE); assert (16 * length full_quads_LE == length full_blocks); assert (length cipher_bytes_full_LE == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_BE alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_BE alg key (inc32 icb (i + j)) ))) = aes_encrypt_LE_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_BE alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal_LE) (alg:algorithm) (key:aes_key_LE alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_BE alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_LE alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb_BE:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_LE_reveal (); let p = le_seq_quad32_to_bytes plain in assert (length p % 16 == 0); let plain_quads_LE = le_bytes_to_seq_quad32 p in let cipher_quads_LE = gctr_encrypt_recursive icb_BE plain_quads_LE alg key 0 in let cipher_bytes = le_seq_quad32_to_bytes cipher_quads_LE in le_bytes_to_seq_quad32_to_bytes plain; () (* Want to show that: slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, out_b))) 0 num_bytes == gctr_encrypt_LE icb_BE (slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, in_b))) 0 num_bytes) ... We know that slice (buffer128_as_seq(mem, out_b) 0 num_blocks == gctr_encrypt_recursive icb_BE (slice buffer128_as_seq(mem, in_b) 0 num_blocks) ... And we know that: get_mem out_b num_blocks == gctr_encrypt_block(icb_BE, (get_mem inb num_blocks), alg, key, num_blocks); Internally gctr_encrypt_LE will compute: full_blocks, final_block = split (slice (le_seq_quad32_to_bytes (buffer128_as_seq(mem, in_b))) 0 num_bytes) (num_blocks * 16) We'd like to show that Step1: le_bytes_to_seq_quad32 full_blocks == slice buffer128_as_seq(mem, in_b) 0 num_blocks and Step2: final_block == slice (le_quad32_to_bytes (get_mem inb num_blocks)) 0 num_extra Then we need to break down the byte-level effects of gctr_encrypt_block to show that even though the padded version of final_block differs from (get_mem inb num_blocks), after we slice it at the end, we end up with the same value *) let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (le_seq_quad32_to_bytes p) 0 num_bytes) (num_blocks * 16) in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_LE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (le_seq_quad32_to_bytes p) 0 num_bytes) (num_blocks * 16) in let full_quads_LE = le_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (le_seq_quad32_to_bytes p) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (le_seq_quad32_to_bytes p) 0 (num_blocks * 16)); slice_commutes_le_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == le_seq_quad32_to_bytes (slice p 0 num_blocks)); le_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_LE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishl_32 (x:nat32) (k:nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32)
false
false
Vale.AES.GCTR.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_ishl_32 (x: nat32) (k: nat) : Lemma (ensures ishl #pow2_32 x k == x * pow2 k % pow2_32)
[]
Vale.AES.GCTR.lemma_ishl_32
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat32 -> k: Prims.nat -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.ishl x k == x * Prims.pow2 k % Vale.Def.Words_s.pow2_32)
{ "end_col": 4, "end_line": 283, "start_col": 2, "start_line": 281 }