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
FStar.Pervasives.Lemma
val modifies_1_modifies (#a: Type) (b: B.buffer a) (h1 h2: HS.mem) : Lemma (requires (B.modifies_1 b h1 h2)) (ensures (modifies (loc_buffer b) h1 h2)) [SMTPat (B.modifies_1 b h1 h2)]
[ { "abbrev": true, "full_module": "FStar.ModifiesGen", "short_module": "MG" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "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_1_modifies #a b h1 h2 = B.lemma_reveal_modifies_1 b h1 h2; MG.modifies_intro (loc_buffer b) h1 h2 (fun _ -> ()) (fun t' pre' b' -> MG.loc_disjoint_sym (loc_mreference b') (loc_buffer b); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) true (HS.frameOf b') (Set.singleton (HS.as_addr b')) ) (fun t' pre' b' -> ()) (fun r n -> ()) (fun r' a' b' -> MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b) #(B.as_addr b) b' (LocBuffer b) )
val modifies_1_modifies (#a: Type) (b: B.buffer a) (h1 h2: HS.mem) : Lemma (requires (B.modifies_1 b h1 h2)) (ensures (modifies (loc_buffer b) h1 h2)) [SMTPat (B.modifies_1 b h1 h2)] let modifies_1_modifies #a b h1 h2 =
false
null
true
B.lemma_reveal_modifies_1 b h1 h2; MG.modifies_intro (loc_buffer b) h1 h2 (fun _ -> ()) (fun t' pre' b' -> MG.loc_disjoint_sym (loc_mreference b') (loc_buffer b); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) true (HS.frameOf b') (Set.singleton (HS.as_addr b'))) (fun t' pre' b' -> ()) (fun r n -> ()) (fun r' a' b' -> MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b) #(B.as_addr b) b' (LocBuffer b))
{ "checked_file": "FStar.Modifies.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": true, "source_file": "FStar.Modifies.fst" }
[ "lemma" ]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "FStar.ModifiesGen.modifies_intro", "FStar.Modifies.aloc", "FStar.Modifies.cls", "FStar.Modifies.loc_buffer", "FStar.Monotonic.HyperHeap.rid", "Prims.unit", "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mreference", "FStar.ModifiesGen.loc_disjoint_aloc_addresses_elim", "FStar.Buffer.frameOf", "FStar.Buffer.as_addr", "FStar.Modifies.LocBuffer", "FStar.Monotonic.HyperStack.frameOf", "FStar.Set.singleton", "Prims.nat", "FStar.Monotonic.HyperStack.as_addr", "FStar.ModifiesGen.loc_disjoint_sym", "FStar.Modifies.loc_mreference", "FStar.ModifiesGen.loc_disjoint_aloc_elim", "FStar.Buffer.lemma_reveal_modifies_1" ]
[]
(* 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 FStar.Modifies module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = FStar.Buffer module U32 = FStar.UInt32 noeq type loc_aux : Type = | LocBuffer: (#t: Type) -> (b: B.buffer t) -> loc_aux let loc_aux_in_addr (l: loc_aux) (r: HS.rid) (n: nat) : GTot Type0 = match l with | LocBuffer b -> B.frameOf b == r /\ B.as_addr b == n let aloc (r: HS.rid) (n: nat) : Tot (Type u#1) = (l: loc_aux { loc_aux_in_addr l r n } ) let loc_aux_includes_buffer (#a: Type) (s: loc_aux) (b: B.buffer a) : GTot Type0 = match s with | LocBuffer #a0 b0 -> a == a0 /\ b0 `B.includes` b let loc_aux_includes (s1 s2: loc_aux) : GTot Type0 (decreases s2) = match s2 with | LocBuffer b -> loc_aux_includes_buffer s1 b let loc_aux_includes_refl (s: loc_aux) : Lemma (loc_aux_includes s s) = () let loc_aux_includes_buffer_includes (#a: Type) (s: loc_aux) (b1 b2: B.buffer a) : Lemma (requires (loc_aux_includes_buffer s b1 /\ b1 `B.includes` b2)) (ensures (loc_aux_includes_buffer s b2)) = () let loc_aux_includes_loc_aux_includes_buffer (#a: Type) (s1 s2: loc_aux) (b: B.buffer a) : Lemma (requires (loc_aux_includes s1 s2 /\ loc_aux_includes_buffer s2 b)) (ensures (loc_aux_includes_buffer s1 b)) = match s2 with | LocBuffer b2 -> loc_aux_includes_buffer_includes s1 b2 b let loc_aux_includes_trans (s1 s2 s3: loc_aux) : Lemma (requires (loc_aux_includes s1 s2 /\ loc_aux_includes s2 s3)) (ensures (loc_aux_includes s1 s3)) = match s3 with | LocBuffer b -> loc_aux_includes_loc_aux_includes_buffer s1 s2 b (* the following is necessary because `decreases` messes up 2nd-order unification with `Classical.forall_intro_3` *) let loc_aux_includes_trans' (s1 s2: loc_aux) (s3: loc_aux) : Lemma ((loc_aux_includes s1 s2 /\ loc_aux_includes s2 s3) ==> loc_aux_includes s1 s3) = Classical.move_requires (loc_aux_includes_trans s1 s2) s3 let loc_aux_disjoint_buffer (l: loc_aux) (#t: Type) (p: B.buffer t) : GTot Type0 = match l with | LocBuffer b -> B.disjoint b p let loc_aux_disjoint (l1 l2: loc_aux) : GTot Type0 = match l2 with | LocBuffer b -> loc_aux_disjoint_buffer l1 b let loc_aux_disjoint_sym (l1 l2: loc_aux) : Lemma (ensures (loc_aux_disjoint l1 l2 <==> loc_aux_disjoint l2 l1)) = () let loc_aux_disjoint_buffer_includes (l: loc_aux) (#t: Type) (p1: B.buffer t) (p2: B.buffer t) : Lemma (requires (loc_aux_disjoint_buffer l p1 /\ p1 `B.includes` p2)) (ensures (loc_aux_disjoint_buffer l p2)) = () let loc_aux_disjoint_loc_aux_includes_buffer (l1 l2: loc_aux) (#t3: Type) (b3: B.buffer t3) : Lemma (requires (loc_aux_disjoint l1 l2 /\ loc_aux_includes_buffer l2 b3)) (ensures (loc_aux_disjoint_buffer l1 b3)) = match l2 with | LocBuffer b2 -> loc_aux_disjoint_buffer_includes l1 b2 b3 let loc_aux_disjoint_loc_aux_includes (l1 l2 l3: loc_aux) : Lemma (requires (loc_aux_disjoint l1 l2 /\ loc_aux_includes l2 l3)) (ensures (loc_aux_disjoint l1 l3)) = match l3 with | LocBuffer b3 -> loc_aux_disjoint_loc_aux_includes_buffer l1 l2 b3 let loc_aux_preserved (l: loc_aux) (h1 h2: HS.mem) : GTot Type0 = match l with | LocBuffer b -> ( B.live h1 b ) ==> ( B.live h2 b /\ B.as_seq h2 b == B.as_seq h1 b ) module MG = FStar.ModifiesGen let cls : MG.cls aloc = MG.Cls #aloc (fun #r #a -> loc_aux_includes) (fun #r #a x -> ()) (fun #r #a x1 x2 x3 -> ()) (fun #r #a -> loc_aux_disjoint) (fun #r #a x1 x2 -> ()) (fun #r #a larger1 larger2 smaller1 smaller2 -> ()) (fun #r #a -> loc_aux_preserved) (fun #r #a x h -> ()) (fun #r #a x h1 h2 h3 -> ()) (fun #r #a b h1 h2 f -> match b with | LocBuffer b' -> let g () : Lemma (requires (B.live h1 b')) (ensures (loc_aux_preserved b h1 h2)) = f _ _ (B.content b') in Classical.move_requires g () ) let loc = MG.loc cls let loc_none = MG.loc_none let loc_union = MG.loc_union let loc_union_idem = MG.loc_union_idem let loc_union_comm = MG.loc_union_comm let loc_union_assoc = MG.loc_union_assoc let loc_union_loc_none_l = MG.loc_union_loc_none_l let loc_union_loc_none_r = MG.loc_union_loc_none_r let loc_buffer #t b = MG.loc_of_aloc #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let loc_addresses = MG.loc_addresses let loc_regions = MG.loc_regions let loc_includes = MG.loc_includes let loc_includes_refl = MG.loc_includes_refl let loc_includes_trans = MG.loc_includes_trans let loc_includes_union_r = MG.loc_includes_union_r let loc_includes_union_l = MG.loc_includes_union_l let loc_includes_none = MG.loc_includes_none let loc_includes_buffer #t b1 b2 = MG.loc_includes_aloc #_ #cls #(B.frameOf b1) #(B.as_addr b1) (LocBuffer b1) (LocBuffer b2) let loc_includes_gsub_buffer_r l #t b i len = loc_includes_trans l (loc_buffer b) (loc_buffer (B.sub b i len)) let loc_includes_gsub_buffer_l #t b i1 len1 i2 len2 = () let loc_includes_addresses_buffer #t preserve_liveness r s p = MG.loc_includes_addresses_aloc #_ #cls preserve_liveness r s #(B.as_addr p) (LocBuffer p) let loc_includes_region_buffer #t preserve_liveness s b = MG.loc_includes_region_aloc #_ #cls preserve_liveness s #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let loc_includes_region_addresses = MG.loc_includes_region_addresses #_ #cls let loc_includes_region_region = MG.loc_includes_region_region #_ #cls let loc_includes_region_union_l = MG.loc_includes_region_union_l let loc_includes_addresses_addresses = MG.loc_includes_addresses_addresses #_ cls let loc_disjoint = MG.loc_disjoint let loc_disjoint_sym = MG.loc_disjoint_sym let loc_disjoint_none_r = MG.loc_disjoint_none_r let loc_disjoint_union_r = MG.loc_disjoint_union_r let loc_disjoint_includes = MG.loc_disjoint_includes let loc_disjoint_buffer #t1 #t2 b1 b2 = MG.loc_disjoint_aloc_intro #_ #cls #(B.frameOf b1) #(B.as_addr b1) #(B.frameOf b2) #(B.as_addr b2) (LocBuffer b1) (LocBuffer b2) let loc_disjoint_gsub_buffer #t b i1 len1 i2 len2 = () let loc_disjoint_addresses = MG.loc_disjoint_addresses #_ #cls let loc_disjoint_buffer_addresses #t p preserve_liveness r n = MG.loc_disjoint_aloc_addresses_intro #_ #cls #(B.frameOf p) #(B.as_addr p) (LocBuffer p) preserve_liveness r n let loc_disjoint_regions = MG.loc_disjoint_regions #_ #cls let modifies = MG.modifies let modifies_mreference_elim = MG.modifies_mreference_elim let modifies_buffer_elim #t1 b p h h' = MG.modifies_aloc_elim #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) p h h' let modifies_refl = MG.modifies_refl let modifies_loc_includes = MG.modifies_loc_includes let address_liveness_insensitive_locs = MG.address_liveness_insensitive_locs _ let region_liveness_insensitive_locs = MG.region_liveness_insensitive_locs _ let address_liveness_insensitive_buffer #t b = MG.loc_includes_address_liveness_insensitive_locs_aloc #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let address_liveness_insensitive_addresses = MG.loc_includes_address_liveness_insensitive_locs_addresses cls let region_liveness_insensitive_buffer #t b = MG.loc_includes_region_liveness_insensitive_locs_loc_of_aloc #_ cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let region_liveness_insensitive_addresses = MG.loc_includes_region_liveness_insensitive_locs_loc_addresses cls let region_liveness_insensitive_regions = MG.loc_includes_region_liveness_insensitive_locs_loc_regions cls let region_liveness_insensitive_address_liveness_insensitive = MG.loc_includes_region_liveness_insensitive_locs_address_liveness_insensitive_locs cls let modifies_liveness_insensitive_mreference = MG.modifies_preserves_liveness let modifies_liveness_insensitive_buffer l1 l2 h h' #t x = MG.modifies_preserves_liveness_strong l1 l2 h h' (B.content x) (LocBuffer x) let modifies_liveness_insensitive_region = MG.modifies_preserves_region_liveness let modifies_liveness_insensitive_region_mreference = MG.modifies_preserves_region_liveness_reference let modifies_liveness_insensitive_region_buffer l1 l2 h h' #t x = MG.modifies_preserves_region_liveness_aloc l1 l2 h h' #(B.frameOf x) #(B.as_addr x) (LocBuffer x) let modifies_trans = MG.modifies_trans let modifies_only_live_regions = MG.modifies_only_live_regions let no_upd_fresh_region = MG.no_upd_fresh_region let modifies_fresh_frame_popped = MG.modifies_fresh_frame_popped let modifies_loc_regions_intro = MG.modifies_loc_regions_intro #_ #cls let modifies_loc_addresses_intro = MG.modifies_loc_addresses_intro let modifies_ralloc_post = MG.modifies_ralloc_post #_ #cls let modifies_salloc_post = MG.modifies_salloc_post #_ #cls let modifies_free = MG.modifies_free #_ #cls let modifies_none_modifies = MG.modifies_none_modifies #_ #cls let modifies_buffer_none_modifies h1 h2 = MG.modifies_none_intro #_ #cls h1 h2 (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) let modifies_0_modifies h1 h2 = B.lemma_reveal_modifies_0 h1 h2; MG.modifies_none_intro #_ #cls h1 h2 (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ())
false
false
FStar.Modifies.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 modifies_1_modifies (#a: Type) (b: B.buffer a) (h1 h2: HS.mem) : Lemma (requires (B.modifies_1 b h1 h2)) (ensures (modifies (loc_buffer b) h1 h2)) [SMTPat (B.modifies_1 b h1 h2)]
[]
FStar.Modifies.modifies_1_modifies
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: FStar.Buffer.buffer a -> h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.Buffer.modifies_1 b h1 h2) (ensures FStar.Modifies.modifies (FStar.Modifies.loc_buffer b) h1 h2) [SMTPat (FStar.Buffer.modifies_1 b h1 h2)]
{ "end_col": 5, "end_line": 353, "start_col": 2, "start_line": 342 }
FStar.Pervasives.Lemma
val free_does_not_contain_addr (#a: Type0) (#rel: Preorder.preorder a) (r: HS.mreference a rel) (m: HS.mem) (x: HS.rid * nat) : Lemma (requires ( HS.is_mm r /\ m `HS.contains` r /\ fst x == HS.frameOf r /\ snd x == HS.as_addr r )) (ensures ( HS.free r m `does_not_contain_addr` x )) [SMTPat (HS.free r m `does_not_contain_addr` x)]
[ { "abbrev": true, "full_module": "FStar.ModifiesGen", "short_module": "MG" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "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 free_does_not_contain_addr = MG.free_does_not_contain_addr
val free_does_not_contain_addr (#a: Type0) (#rel: Preorder.preorder a) (r: HS.mreference a rel) (m: HS.mem) (x: HS.rid * nat) : Lemma (requires ( HS.is_mm r /\ m `HS.contains` r /\ fst x == HS.frameOf r /\ snd x == HS.as_addr r )) (ensures ( HS.free r m `does_not_contain_addr` x )) [SMTPat (HS.free r m `does_not_contain_addr` x)] let free_does_not_contain_addr =
false
null
true
MG.free_does_not_contain_addr
{ "checked_file": "FStar.Modifies.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": true, "source_file": "FStar.Modifies.fst" }
[ "lemma" ]
[ "FStar.ModifiesGen.free_does_not_contain_addr" ]
[]
(* 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 FStar.Modifies module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = FStar.Buffer module U32 = FStar.UInt32 noeq type loc_aux : Type = | LocBuffer: (#t: Type) -> (b: B.buffer t) -> loc_aux let loc_aux_in_addr (l: loc_aux) (r: HS.rid) (n: nat) : GTot Type0 = match l with | LocBuffer b -> B.frameOf b == r /\ B.as_addr b == n let aloc (r: HS.rid) (n: nat) : Tot (Type u#1) = (l: loc_aux { loc_aux_in_addr l r n } ) let loc_aux_includes_buffer (#a: Type) (s: loc_aux) (b: B.buffer a) : GTot Type0 = match s with | LocBuffer #a0 b0 -> a == a0 /\ b0 `B.includes` b let loc_aux_includes (s1 s2: loc_aux) : GTot Type0 (decreases s2) = match s2 with | LocBuffer b -> loc_aux_includes_buffer s1 b let loc_aux_includes_refl (s: loc_aux) : Lemma (loc_aux_includes s s) = () let loc_aux_includes_buffer_includes (#a: Type) (s: loc_aux) (b1 b2: B.buffer a) : Lemma (requires (loc_aux_includes_buffer s b1 /\ b1 `B.includes` b2)) (ensures (loc_aux_includes_buffer s b2)) = () let loc_aux_includes_loc_aux_includes_buffer (#a: Type) (s1 s2: loc_aux) (b: B.buffer a) : Lemma (requires (loc_aux_includes s1 s2 /\ loc_aux_includes_buffer s2 b)) (ensures (loc_aux_includes_buffer s1 b)) = match s2 with | LocBuffer b2 -> loc_aux_includes_buffer_includes s1 b2 b let loc_aux_includes_trans (s1 s2 s3: loc_aux) : Lemma (requires (loc_aux_includes s1 s2 /\ loc_aux_includes s2 s3)) (ensures (loc_aux_includes s1 s3)) = match s3 with | LocBuffer b -> loc_aux_includes_loc_aux_includes_buffer s1 s2 b (* the following is necessary because `decreases` messes up 2nd-order unification with `Classical.forall_intro_3` *) let loc_aux_includes_trans' (s1 s2: loc_aux) (s3: loc_aux) : Lemma ((loc_aux_includes s1 s2 /\ loc_aux_includes s2 s3) ==> loc_aux_includes s1 s3) = Classical.move_requires (loc_aux_includes_trans s1 s2) s3 let loc_aux_disjoint_buffer (l: loc_aux) (#t: Type) (p: B.buffer t) : GTot Type0 = match l with | LocBuffer b -> B.disjoint b p let loc_aux_disjoint (l1 l2: loc_aux) : GTot Type0 = match l2 with | LocBuffer b -> loc_aux_disjoint_buffer l1 b let loc_aux_disjoint_sym (l1 l2: loc_aux) : Lemma (ensures (loc_aux_disjoint l1 l2 <==> loc_aux_disjoint l2 l1)) = () let loc_aux_disjoint_buffer_includes (l: loc_aux) (#t: Type) (p1: B.buffer t) (p2: B.buffer t) : Lemma (requires (loc_aux_disjoint_buffer l p1 /\ p1 `B.includes` p2)) (ensures (loc_aux_disjoint_buffer l p2)) = () let loc_aux_disjoint_loc_aux_includes_buffer (l1 l2: loc_aux) (#t3: Type) (b3: B.buffer t3) : Lemma (requires (loc_aux_disjoint l1 l2 /\ loc_aux_includes_buffer l2 b3)) (ensures (loc_aux_disjoint_buffer l1 b3)) = match l2 with | LocBuffer b2 -> loc_aux_disjoint_buffer_includes l1 b2 b3 let loc_aux_disjoint_loc_aux_includes (l1 l2 l3: loc_aux) : Lemma (requires (loc_aux_disjoint l1 l2 /\ loc_aux_includes l2 l3)) (ensures (loc_aux_disjoint l1 l3)) = match l3 with | LocBuffer b3 -> loc_aux_disjoint_loc_aux_includes_buffer l1 l2 b3 let loc_aux_preserved (l: loc_aux) (h1 h2: HS.mem) : GTot Type0 = match l with | LocBuffer b -> ( B.live h1 b ) ==> ( B.live h2 b /\ B.as_seq h2 b == B.as_seq h1 b ) module MG = FStar.ModifiesGen let cls : MG.cls aloc = MG.Cls #aloc (fun #r #a -> loc_aux_includes) (fun #r #a x -> ()) (fun #r #a x1 x2 x3 -> ()) (fun #r #a -> loc_aux_disjoint) (fun #r #a x1 x2 -> ()) (fun #r #a larger1 larger2 smaller1 smaller2 -> ()) (fun #r #a -> loc_aux_preserved) (fun #r #a x h -> ()) (fun #r #a x h1 h2 h3 -> ()) (fun #r #a b h1 h2 f -> match b with | LocBuffer b' -> let g () : Lemma (requires (B.live h1 b')) (ensures (loc_aux_preserved b h1 h2)) = f _ _ (B.content b') in Classical.move_requires g () ) let loc = MG.loc cls let loc_none = MG.loc_none let loc_union = MG.loc_union let loc_union_idem = MG.loc_union_idem let loc_union_comm = MG.loc_union_comm let loc_union_assoc = MG.loc_union_assoc let loc_union_loc_none_l = MG.loc_union_loc_none_l let loc_union_loc_none_r = MG.loc_union_loc_none_r let loc_buffer #t b = MG.loc_of_aloc #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let loc_addresses = MG.loc_addresses let loc_regions = MG.loc_regions let loc_includes = MG.loc_includes let loc_includes_refl = MG.loc_includes_refl let loc_includes_trans = MG.loc_includes_trans let loc_includes_union_r = MG.loc_includes_union_r let loc_includes_union_l = MG.loc_includes_union_l let loc_includes_none = MG.loc_includes_none let loc_includes_buffer #t b1 b2 = MG.loc_includes_aloc #_ #cls #(B.frameOf b1) #(B.as_addr b1) (LocBuffer b1) (LocBuffer b2) let loc_includes_gsub_buffer_r l #t b i len = loc_includes_trans l (loc_buffer b) (loc_buffer (B.sub b i len)) let loc_includes_gsub_buffer_l #t b i1 len1 i2 len2 = () let loc_includes_addresses_buffer #t preserve_liveness r s p = MG.loc_includes_addresses_aloc #_ #cls preserve_liveness r s #(B.as_addr p) (LocBuffer p) let loc_includes_region_buffer #t preserve_liveness s b = MG.loc_includes_region_aloc #_ #cls preserve_liveness s #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let loc_includes_region_addresses = MG.loc_includes_region_addresses #_ #cls let loc_includes_region_region = MG.loc_includes_region_region #_ #cls let loc_includes_region_union_l = MG.loc_includes_region_union_l let loc_includes_addresses_addresses = MG.loc_includes_addresses_addresses #_ cls let loc_disjoint = MG.loc_disjoint let loc_disjoint_sym = MG.loc_disjoint_sym let loc_disjoint_none_r = MG.loc_disjoint_none_r let loc_disjoint_union_r = MG.loc_disjoint_union_r let loc_disjoint_includes = MG.loc_disjoint_includes let loc_disjoint_buffer #t1 #t2 b1 b2 = MG.loc_disjoint_aloc_intro #_ #cls #(B.frameOf b1) #(B.as_addr b1) #(B.frameOf b2) #(B.as_addr b2) (LocBuffer b1) (LocBuffer b2) let loc_disjoint_gsub_buffer #t b i1 len1 i2 len2 = () let loc_disjoint_addresses = MG.loc_disjoint_addresses #_ #cls let loc_disjoint_buffer_addresses #t p preserve_liveness r n = MG.loc_disjoint_aloc_addresses_intro #_ #cls #(B.frameOf p) #(B.as_addr p) (LocBuffer p) preserve_liveness r n let loc_disjoint_regions = MG.loc_disjoint_regions #_ #cls let modifies = MG.modifies let modifies_mreference_elim = MG.modifies_mreference_elim let modifies_buffer_elim #t1 b p h h' = MG.modifies_aloc_elim #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) p h h' let modifies_refl = MG.modifies_refl let modifies_loc_includes = MG.modifies_loc_includes let address_liveness_insensitive_locs = MG.address_liveness_insensitive_locs _ let region_liveness_insensitive_locs = MG.region_liveness_insensitive_locs _ let address_liveness_insensitive_buffer #t b = MG.loc_includes_address_liveness_insensitive_locs_aloc #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let address_liveness_insensitive_addresses = MG.loc_includes_address_liveness_insensitive_locs_addresses cls let region_liveness_insensitive_buffer #t b = MG.loc_includes_region_liveness_insensitive_locs_loc_of_aloc #_ cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) let region_liveness_insensitive_addresses = MG.loc_includes_region_liveness_insensitive_locs_loc_addresses cls let region_liveness_insensitive_regions = MG.loc_includes_region_liveness_insensitive_locs_loc_regions cls let region_liveness_insensitive_address_liveness_insensitive = MG.loc_includes_region_liveness_insensitive_locs_address_liveness_insensitive_locs cls let modifies_liveness_insensitive_mreference = MG.modifies_preserves_liveness let modifies_liveness_insensitive_buffer l1 l2 h h' #t x = MG.modifies_preserves_liveness_strong l1 l2 h h' (B.content x) (LocBuffer x) let modifies_liveness_insensitive_region = MG.modifies_preserves_region_liveness let modifies_liveness_insensitive_region_mreference = MG.modifies_preserves_region_liveness_reference let modifies_liveness_insensitive_region_buffer l1 l2 h h' #t x = MG.modifies_preserves_region_liveness_aloc l1 l2 h h' #(B.frameOf x) #(B.as_addr x) (LocBuffer x) let modifies_trans = MG.modifies_trans let modifies_only_live_regions = MG.modifies_only_live_regions let no_upd_fresh_region = MG.no_upd_fresh_region let modifies_fresh_frame_popped = MG.modifies_fresh_frame_popped let modifies_loc_regions_intro = MG.modifies_loc_regions_intro #_ #cls let modifies_loc_addresses_intro = MG.modifies_loc_addresses_intro let modifies_ralloc_post = MG.modifies_ralloc_post #_ #cls let modifies_salloc_post = MG.modifies_salloc_post #_ #cls let modifies_free = MG.modifies_free #_ #cls let modifies_none_modifies = MG.modifies_none_modifies #_ #cls let modifies_buffer_none_modifies h1 h2 = MG.modifies_none_intro #_ #cls h1 h2 (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) let modifies_0_modifies h1 h2 = B.lemma_reveal_modifies_0 h1 h2; MG.modifies_none_intro #_ #cls h1 h2 (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) let modifies_1_modifies #a b h1 h2 = B.lemma_reveal_modifies_1 b h1 h2; MG.modifies_intro (loc_buffer b) h1 h2 (fun _ -> ()) (fun t' pre' b' -> MG.loc_disjoint_sym (loc_mreference b') (loc_buffer b); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b) #(B.as_addr b) (LocBuffer b) true (HS.frameOf b') (Set.singleton (HS.as_addr b')) ) (fun t' pre' b' -> ()) (fun r n -> ()) (fun r' a' b' -> MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b) #(B.as_addr b) b' (LocBuffer b) ) let modifies_2_modifies #a1 #a2 b1 b2 h1 h2 = B.lemma_reveal_modifies_2 b1 b2 h1 h2; MG.modifies_intro (loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2 (fun _ -> ()) (fun t' pre' b' -> loc_disjoint_includes (loc_mreference b') (loc_union (loc_buffer b1) (loc_buffer b2)) (loc_mreference b') (loc_buffer b1); loc_disjoint_sym (loc_mreference b') (loc_buffer b1); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b1) #(B.as_addr b1) (LocBuffer b1) true (HS.frameOf b') (Set.singleton (HS.as_addr b')); loc_disjoint_includes (loc_mreference b') (loc_union (loc_buffer b1) (loc_buffer b2)) (loc_mreference b') (loc_buffer b2); loc_disjoint_sym (loc_mreference b') (loc_buffer b2); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b2) #(B.as_addr b2) (LocBuffer b2) true (HS.frameOf b') (Set.singleton (HS.as_addr b')) ) (fun _ _ _ -> ()) (fun _ _ -> ()) (fun r' a' b' -> loc_disjoint_includes (MG.loc_of_aloc b') (loc_union (loc_buffer b1) (loc_buffer b2)) (MG.loc_of_aloc b') (loc_buffer b1); MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b1) #(B.as_addr b1) b' (LocBuffer b1); loc_disjoint_includes (MG.loc_of_aloc b') (loc_union (loc_buffer b1) (loc_buffer b2)) (MG.loc_of_aloc b') (loc_buffer b2); MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b2) #(B.as_addr b2) b' (LocBuffer b2) ) #set-options "--z3rlimit 20" let modifies_3_modifies #a1 #a2 #a3 b1 b2 b3 h1 h2 = B.lemma_reveal_modifies_3 b1 b2 b3 h1 h2; MG.modifies_intro (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2 (fun _ -> ()) (fun t' pre' b' -> loc_disjoint_includes (loc_mreference b') (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) (loc_mreference b') (loc_buffer b1); loc_disjoint_sym (loc_mreference b') (loc_buffer b1); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b1) #(B.as_addr b1) (LocBuffer b1) true (HS.frameOf b') (Set.singleton (HS.as_addr b')); loc_disjoint_includes (loc_mreference b') (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) (loc_mreference b') (loc_buffer b2); loc_disjoint_sym (loc_mreference b') (loc_buffer b2); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b2) #(B.as_addr b2) (LocBuffer b2) true (HS.frameOf b') (Set.singleton (HS.as_addr b')); loc_disjoint_includes (loc_mreference b') (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) (loc_mreference b') (loc_buffer b3); loc_disjoint_sym (loc_mreference b') (loc_buffer b3); MG.loc_disjoint_aloc_addresses_elim #_ #cls #(B.frameOf b3) #(B.as_addr b3) (LocBuffer b3) true (HS.frameOf b') (Set.singleton (HS.as_addr b')) ) (fun _ _ _ -> ()) (fun _ _ -> ()) (fun r' a' b' -> loc_disjoint_includes (MG.loc_of_aloc b') (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) (MG.loc_of_aloc b') (loc_buffer b1); MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b1) #(B.as_addr b1) b' (LocBuffer b1); loc_disjoint_includes (MG.loc_of_aloc b') (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) (MG.loc_of_aloc b') (loc_buffer b2); MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b2) #(B.as_addr b2) b' (LocBuffer b2); loc_disjoint_includes (MG.loc_of_aloc b') (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) (MG.loc_of_aloc b') (loc_buffer b3); MG.loc_disjoint_aloc_elim #_ #cls #r' #a' #(B.frameOf b3) #(B.as_addr b3) b' (LocBuffer b3) ) #reset-options let modifies_buffer_rcreate_post_common #a r init len b h0 h1 = MG.modifies_none_intro #_ #cls h0 h1 (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) let mreference_live_buffer_unused_in_disjoint #t1 #pre #t2 h b1 b2 = loc_disjoint_includes (loc_freed_mreference b1) (loc_freed_mreference (B.content b2)) (loc_freed_mreference b1) (loc_buffer b2) let buffer_live_mreference_unused_in_disjoint #t1 #t2 #pre h b1 b2 = loc_disjoint_includes (loc_freed_mreference (B.content b1)) (loc_freed_mreference b2) (loc_buffer b1) (loc_freed_mreference b2) let does_not_contain_addr = MG.does_not_contain_addr let not_live_region_does_not_contain_addr = MG.not_live_region_does_not_contain_addr let unused_in_does_not_contain_addr = MG.unused_in_does_not_contain_addr let addr_unused_in_does_not_contain_addr = MG.addr_unused_in_does_not_contain_addr
false
false
FStar.Modifies.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 free_does_not_contain_addr (#a: Type0) (#rel: Preorder.preorder a) (r: HS.mreference a rel) (m: HS.mem) (x: HS.rid * nat) : Lemma (requires ( HS.is_mm r /\ m `HS.contains` r /\ fst x == HS.frameOf r /\ snd x == HS.as_addr r )) (ensures ( HS.free r m `does_not_contain_addr` x )) [SMTPat (HS.free r m `does_not_contain_addr` x)]
[]
FStar.Modifies.free_does_not_contain_addr
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.Monotonic.HyperStack.mreference a rel -> m: FStar.Monotonic.HyperStack.mem -> x: (FStar.Monotonic.HyperHeap.rid * Prims.nat) -> FStar.Pervasives.Lemma (requires FStar.Monotonic.HyperStack.is_mm r /\ FStar.Monotonic.HyperStack.contains m r /\ FStar.Pervasives.Native.fst x == FStar.Monotonic.HyperStack.frameOf r /\ FStar.Pervasives.Native.snd x == FStar.Monotonic.HyperStack.as_addr r) (ensures FStar.Modifies.does_not_contain_addr (FStar.Monotonic.HyperStack.free r m) x) [SMTPat (FStar.Modifies.does_not_contain_addr (FStar.Monotonic.HyperStack.free r m) x)]
{ "end_col": 62, "end_line": 426, "start_col": 33, "start_line": 426 }
FStar.Pervasives.Lemma
val lemma_to_of (s:machine_state) : Lemma (ensures state_to_S (state_of_S s) == {s with Ms.ms_trace = []})
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_to_of s = let open Ms in let s' = state_of_S s in let s'' = state_to_S s' in assert (feq s.ms_regs s''.ms_regs); assert (feq s.ms_flags s''.ms_flags); VSS.lemma_stack_to_from s.ms_stack; ()
val lemma_to_of (s:machine_state) : Lemma (ensures state_to_S (state_of_S s) == {s with Ms.ms_trace = []}) let lemma_to_of s =
false
null
true
let open Ms in let s' = state_of_S s in let s'' = state_to_S s' in assert (feq s.ms_regs s''.ms_regs); assert (feq s.ms_flags s''.ms_flags); VSS.lemma_stack_to_from s.ms_stack; ()
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.X64.StateLemmas.machine_state", "Prims.unit", "Vale.X64.Stack_Sems.lemma_stack_to_from", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Vale.X64.Machine_s.flag", "Vale.X64.Machine_Semantics_s.flag_val_t", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.t_reg", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.StateLemmas.state_to_S", "Vale.X64.State.vale_state", "Vale.X64.StateLemmas.state_of_S" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2" let lemma_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get128 h ptr = MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () //let lemma_valid_buffer_read64 h b i = // lemma_valid_mem64 b i h //let lemma_valid_buffer_read128 h b i = // lemma_valid_mem128 b i h let lemma_load_buffer_read64 h b i = lemma_load_mem64 b i h let lemma_load_buffer_read128 h b i = lemma_load_mem128 b i h #reset-options "--z3rlimit 50" #restart-solver let lemma_to_eval_operand s o = allow_inversion tmaddr; allow_inversion maddr #reset-options "--initial_fuel 2 --max_fuel 2" //let lemma_to_eval_xmm s x = () //#reset-options "--initial_fuel 1 --max_fuel 1 --z3rlimit 50" //#restart-solver //let lemma_to_eval_operand128 s o = // allow_inversion tmaddr; // allow_inversion maddr // //#reset-options "--initial_fuel 1 --max_fuel 1 --z3rlimit 50" //#restart-solver //let lemma_to_valid_operand s o = // allow_inversion tmaddr; // allow_inversion maddr
false
false
Vale.X64.StateLemmas.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_to_of (s:machine_state) : Lemma (ensures state_to_S (state_of_S s) == {s with Ms.ms_trace = []})
[]
Vale.X64.StateLemmas.lemma_to_of
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.StateLemmas.machine_state -> FStar.Pervasives.Lemma (ensures Vale.X64.StateLemmas.state_to_S (Vale.X64.StateLemmas.state_of_S s) == Vale.X64.Machine_Semantics_s.Mkmachine_state (Mkmachine_state?.ms_ok s) (Mkmachine_state?.ms_regs s) (Mkmachine_state?.ms_flags s) (Mkmachine_state?.ms_heap s) (Mkmachine_state?.ms_stack s) (Mkmachine_state?.ms_stackTaint s) [])
{ "end_col": 4, "end_line": 80, "start_col": 2, "start_line": 74 }
FStar.Pervasives.Lemma
val lemma_load_mem_get64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures load_mem64 ptr (get_vale_heap h) == get_heap_val64 ptr (heap_get (coerce h))) [SMTPat (load_mem64 ptr (get_vale_heap h))]
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_load_mem_get64 h ptr = MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
val lemma_load_mem_get64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures load_mem64 ptr (get_vale_heap h) == get_heap_val64 ptr (heap_get (coerce h))) [SMTPat (load_mem64 ptr (get_vale_heap h))] let lemma_load_mem_get64 h ptr =
false
null
true
MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.Arch.HeapImpl.vale_full_heap", "Prims.int", "Prims.unit", "Vale.X64.Memory_Sems.lemma_heap_get_heap", "Vale.X64.Memory_Sems.equiv_load_mem64", "Vale.X64.Memory.get_vale_heap" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2" let lemma_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
false
false
Vale.X64.StateLemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 1, "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": 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_load_mem_get64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures load_mem64 ptr (get_vale_heap h) == get_heap_val64 ptr (heap_get (coerce h))) [SMTPat (load_mem64 ptr (get_vale_heap h))]
[]
Vale.X64.StateLemmas.lemma_load_mem_get64
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Arch.HeapImpl.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.X64.Memory.valid_mem64 ptr (Vale.X64.Memory.get_vale_heap h)) (ensures Vale.X64.Memory.load_mem64 ptr (Vale.X64.Memory.get_vale_heap h) == Vale.Arch.MachineHeap_s.get_heap_val64 ptr (Vale.Arch.Heap.heap_get (Vale.X64.StateLemmas.coerce h))) [SMTPat (Vale.X64.Memory.load_mem64 ptr (Vale.X64.Memory.get_vale_heap h))]
{ "end_col": 4, "end_line": 32, "start_col": 2, "start_line": 30 }
FStar.Pervasives.Lemma
val lemma_valid_mem_addr64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures valid_addr64 ptr (heap_get (coerce h))) [SMTPat (valid_mem64 ptr (get_vale_heap h))]
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
val lemma_valid_mem_addr64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures valid_addr64 ptr (heap_get (coerce h))) [SMTPat (valid_mem64 ptr (get_vale_heap h))] let lemma_valid_mem_addr64 h ptr =
false
null
true
MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.Arch.HeapImpl.vale_full_heap", "Prims.int", "Prims.unit", "Vale.X64.Memory_Sems.lemma_heap_get_heap", "Vale.X64.Memory_Sems.bytes_valid64", "Vale.X64.Memory.get_vale_heap" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2"
false
false
Vale.X64.StateLemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 1, "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": 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_valid_mem_addr64 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem64 ptr (get_vale_heap h)) (ensures valid_addr64 ptr (heap_get (coerce h))) [SMTPat (valid_mem64 ptr (get_vale_heap h))]
[]
Vale.X64.StateLemmas.lemma_valid_mem_addr64
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Arch.HeapImpl.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.X64.Memory.valid_mem64 ptr (Vale.X64.Memory.get_vale_heap h)) (ensures Vale.Arch.MachineHeap_s.valid_addr64 ptr (Vale.Arch.Heap.heap_get (Vale.X64.StateLemmas.coerce h))) [SMTPat (Vale.X64.Memory.valid_mem64 ptr (Vale.X64.Memory.get_vale_heap h))]
{ "end_col": 4, "end_line": 22, "start_col": 2, "start_line": 20 }
FStar.Pervasives.Lemma
val lemma_valid_mem_addr128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures valid_addr128 ptr (heap_get (coerce h))) [SMTPat (valid_mem128 ptr (get_vale_heap h))]
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_valid_mem_addr128 h ptr = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
val lemma_valid_mem_addr128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures valid_addr128 ptr (heap_get (coerce h))) [SMTPat (valid_mem128 ptr (get_vale_heap h))] let lemma_valid_mem_addr128 h ptr =
false
null
true
MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.Arch.HeapImpl.vale_full_heap", "Prims.int", "Prims.unit", "Vale.X64.Memory_Sems.lemma_heap_get_heap", "Vale.X64.Memory_Sems.bytes_valid128", "Vale.X64.Memory.get_vale_heap" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2" let lemma_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
false
false
Vale.X64.StateLemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 1, "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": 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_valid_mem_addr128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures valid_addr128 ptr (heap_get (coerce h))) [SMTPat (valid_mem128 ptr (get_vale_heap h))]
[]
Vale.X64.StateLemmas.lemma_valid_mem_addr128
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Arch.HeapImpl.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.X64.Memory.valid_mem128 ptr (Vale.X64.Memory.get_vale_heap h)) (ensures Vale.Arch.MachineHeap_s.valid_addr128 ptr (Vale.Arch.Heap.heap_get (Vale.X64.StateLemmas.coerce h))) [SMTPat (Vale.X64.Memory.valid_mem128 ptr (Vale.X64.Memory.get_vale_heap h))]
{ "end_col": 4, "end_line": 27, "start_col": 2, "start_line": 25 }
FStar.Pervasives.Lemma
val lemma_load_mem_get128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures load_mem128 ptr (get_vale_heap h) == get_heap_val128 ptr (heap_get (coerce h))) [SMTPat (load_mem128 ptr (get_vale_heap h))]
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_load_mem_get128 h ptr = MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
val lemma_load_mem_get128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures load_mem128 ptr (get_vale_heap h) == get_heap_val128 ptr (heap_get (coerce h))) [SMTPat (load_mem128 ptr (get_vale_heap h))] let lemma_load_mem_get128 h ptr =
false
null
true
MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.Arch.HeapImpl.vale_full_heap", "Prims.int", "Prims.unit", "Vale.X64.Memory_Sems.lemma_heap_get_heap", "Vale.X64.Memory_Sems.equiv_load_mem128", "Vale.X64.Memory.get_vale_heap" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2" let lemma_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
false
false
Vale.X64.StateLemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 1, "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": 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_load_mem_get128 (h:vale_full_heap) (ptr:int) : Lemma (requires valid_mem128 ptr (get_vale_heap h)) (ensures load_mem128 ptr (get_vale_heap h) == get_heap_val128 ptr (heap_get (coerce h))) [SMTPat (load_mem128 ptr (get_vale_heap h))]
[]
Vale.X64.StateLemmas.lemma_load_mem_get128
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Arch.HeapImpl.vale_full_heap -> ptr: Prims.int -> FStar.Pervasives.Lemma (requires Vale.X64.Memory.valid_mem128 ptr (Vale.X64.Memory.get_vale_heap h)) (ensures Vale.X64.Memory.load_mem128 ptr (Vale.X64.Memory.get_vale_heap h) == Vale.Arch.MachineHeap_s.get_heap_val128 ptr (Vale.Arch.Heap.heap_get (Vale.X64.StateLemmas.coerce h))) [SMTPat (Vale.X64.Memory.load_mem128 ptr (Vale.X64.Memory.get_vale_heap h))]
{ "end_col": 4, "end_line": 37, "start_col": 2, "start_line": 35 }
FStar.Pervasives.Lemma
val lemma_load_buffer_read128 (h:vale_heap) (b:buffer128) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem128 (buffer_addr b h + 16 * i) h) [SMTPat (buffer_read b i h)]
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_load_buffer_read128 h b i = lemma_load_mem128 b i h
val lemma_load_buffer_read128 (h:vale_heap) (b:buffer128) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem128 (buffer_addr b h + 16 * i) h) [SMTPat (buffer_read b i h)] let lemma_load_buffer_read128 h b i =
false
null
true
lemma_load_mem128 b i h
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.Arch.HeapImpl.vale_heap", "Vale.X64.Memory.buffer128", "Prims.int", "Vale.X64.Memory.lemma_load_mem128", "Prims.unit" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2" let lemma_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get128 h ptr = MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () //let lemma_valid_buffer_read64 h b i = // lemma_valid_mem64 b i h //let lemma_valid_buffer_read128 h b i = // lemma_valid_mem128 b i h let lemma_load_buffer_read64 h b i = lemma_load_mem64 b i h
false
false
Vale.X64.StateLemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 1, "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": 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_load_buffer_read128 (h:vale_heap) (b:buffer128) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem128 (buffer_addr b h + 16 * i) h) [SMTPat (buffer_read b i h)]
[]
Vale.X64.StateLemmas.lemma_load_buffer_read128
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Arch.HeapImpl.vale_heap -> b: Vale.X64.Memory.buffer128 -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.X64.Memory.valid_buffer_read h b i) (ensures Vale.X64.Memory.buffer_read b i h == Vale.X64.Memory.load_mem128 (Vale.X64.Memory.buffer_addr b h + 16 * i) h) [SMTPat (Vale.X64.Memory.buffer_read b i h)]
{ "end_col": 25, "end_line": 49, "start_col": 2, "start_line": 49 }
FStar.Pervasives.Lemma
val lemma_to_eval_operand (s:vale_state) (o:operand64) : Lemma (requires valid_src_operand o s) (ensures eval_operand o s == Ms.eval_operand o (state_to_S s)) [SMTPat (eval_operand o s)]
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_to_eval_operand s o = allow_inversion tmaddr; allow_inversion maddr
val lemma_to_eval_operand (s:vale_state) (o:operand64) : Lemma (requires valid_src_operand o s) (ensures eval_operand o s == Ms.eval_operand o (state_to_S s)) [SMTPat (eval_operand o s)] let lemma_to_eval_operand s o =
false
null
true
allow_inversion tmaddr; allow_inversion maddr
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.X64.State.vale_state", "Vale.X64.Machine_s.operand64", "FStar.Pervasives.allow_inversion", "Vale.X64.Machine_s.maddr", "Prims.unit", "Vale.X64.Machine_s.tmaddr" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2" let lemma_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get128 h ptr = MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () //let lemma_valid_buffer_read64 h b i = // lemma_valid_mem64 b i h //let lemma_valid_buffer_read128 h b i = // lemma_valid_mem128 b i h let lemma_load_buffer_read64 h b i = lemma_load_mem64 b i h let lemma_load_buffer_read128 h b i = lemma_load_mem128 b i h #reset-options "--z3rlimit 50" #restart-solver
false
false
Vale.X64.StateLemmas.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_to_eval_operand (s:vale_state) (o:operand64) : Lemma (requires valid_src_operand o s) (ensures eval_operand o s == Ms.eval_operand o (state_to_S s)) [SMTPat (eval_operand o s)]
[]
Vale.X64.StateLemmas.lemma_to_eval_operand
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.State.vale_state -> o: Vale.X64.Machine_s.operand64 -> FStar.Pervasives.Lemma (requires Vale.X64.State.valid_src_operand o s) (ensures Vale.X64.State.eval_operand o s == Vale.X64.Machine_Semantics_s.eval_operand o (Vale.X64.StateLemmas.state_to_S s)) [SMTPat (Vale.X64.State.eval_operand o s)]
{ "end_col": 23, "end_line": 55, "start_col": 2, "start_line": 54 }
FStar.Pervasives.Lemma
val lemma_load_buffer_read64 (h:vale_heap) (b:buffer64) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem64 (buffer_addr b h + 8 * i) h) [SMTPat (buffer_read b i h)]
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "VST" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.X64.Memory_Sems", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "Vale.X64.Stack_Sems", "short_module": "VSS" }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "Ms" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_load_buffer_read64 h b i = lemma_load_mem64 b i h
val lemma_load_buffer_read64 (h:vale_heap) (b:buffer64) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem64 (buffer_addr b h + 8 * i) h) [SMTPat (buffer_read b i h)] let lemma_load_buffer_read64 h b i =
false
null
true
lemma_load_mem64 b i h
{ "checked_file": "Vale.X64.StateLemmas.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.StateLemmas.fst" }
[ "lemma" ]
[ "Vale.Arch.HeapImpl.vale_heap", "Vale.X64.Memory.buffer64", "Prims.int", "Vale.X64.Memory.lemma_load_mem64", "Prims.unit" ]
[]
module Vale.X64.StateLemmas open FStar.Mul open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.State module BS = Vale.X64.Machine_Semantics_s module MS = Vale.X64.Memory_Sems module ME = Vale.X64.Memory module VST = Vale.X64.Stack_i module VSS = Vale.X64.Stack_Sems module F = FStar.FunctionalExtensionality friend Vale.X64.Memory let same_heap_types = () let use_machine_state_equal () = () #set-options "--max_ifuel 2 --initial_ifuel 2" let lemma_valid_mem_addr64 h ptr = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_valid_mem_addr128 h ptr = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get64 h ptr = MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () let lemma_load_mem_get128 h ptr = MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; () //let lemma_valid_buffer_read64 h b i = // lemma_valid_mem64 b i h //let lemma_valid_buffer_read128 h b i = // lemma_valid_mem128 b i h
false
false
Vale.X64.StateLemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 1, "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": 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_load_buffer_read64 (h:vale_heap) (b:buffer64) (i:int) : Lemma (requires valid_buffer_read h b i) (ensures buffer_read b i h == load_mem64 (buffer_addr b h + 8 * i) h) [SMTPat (buffer_read b i h)]
[]
Vale.X64.StateLemmas.lemma_load_buffer_read64
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Arch.HeapImpl.vale_heap -> b: Vale.X64.Memory.buffer64 -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.X64.Memory.valid_buffer_read h b i) (ensures Vale.X64.Memory.buffer_read b i h == Vale.X64.Memory.load_mem64 (Vale.X64.Memory.buffer_addr b h + 8 * i) h) [SMTPat (Vale.X64.Memory.buffer_read b i h)]
{ "end_col": 24, "end_line": 46, "start_col": 2, "start_line": 46 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "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 bn_mont_nat (#t:limb_t) (k:bn_mont_ctx t) = x:lbignum t k.len{bn_v x < bn_v k.n}
let bn_mont_nat (#t: limb_t) (k: bn_mont_ctx t) =
false
null
false
x: lbignum t k.len {bn_v x < bn_v k.n}
{ "checked_file": "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.MontArithmetic.fsti" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n" ]
[]
module Hacl.Spec.Bignum.MontArithmetic open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module Euclid = FStar.Math.Euclid module M = Hacl.Spec.Montgomery.Lemmas module BN = Hacl.Spec.Bignum #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_mont_ctx_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) = 1 < bn_v n /\ bn_v n % 2 = 1 inline_for_extraction class bn_mont_ctx (t:limb_t) = { len: BN.bn_len t; n: lbignum t len; mu: limb t; r2: lbignum t len } let bn_mont_ctx_inv (#t:limb_t) (k:bn_mont_ctx t) = bn_v k.n < pow2 (bits t * k.len) /\ bn_mont_ctx_pre k.n /\ (1 + bn_v k.n * v k.mu) % pow2 (bits t) == 0 /\ bn_v k.r2 == pow2 (2 * bits t * k.len) % bn_v k.n
false
false
Hacl.Spec.Bignum.MontArithmetic.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mont_nat : k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Type0
[]
Hacl.Spec.Bignum.MontArithmetic.bn_mont_nat
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Type0
{ "end_col": 38, "end_line": 37, "start_col": 2, "start_line": 37 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "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 bn_mont_ctx_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) = 1 < bn_v n /\ bn_v n % 2 = 1
let bn_mont_ctx_pre (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len) =
false
null
false
1 < bn_v n /\ bn_v n % 2 = 1
{ "checked_file": "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.MontArithmetic.fsti" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.logical" ]
[]
module Hacl.Spec.Bignum.MontArithmetic open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module Euclid = FStar.Math.Euclid module M = Hacl.Spec.Montgomery.Lemmas module BN = Hacl.Spec.Bignum #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
false
Hacl.Spec.Bignum.MontArithmetic.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mont_ctx_pre : n: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.logical
[]
Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_pre
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.logical
{ "end_col": 30, "end_line": 17, "start_col": 2, "start_line": 17 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "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 bn_mont_ctx_inv (#t:limb_t) (k:bn_mont_ctx t) = bn_v k.n < pow2 (bits t * k.len) /\ bn_mont_ctx_pre k.n /\ (1 + bn_v k.n * v k.mu) % pow2 (bits t) == 0 /\ bn_v k.r2 == pow2 (2 * bits t * k.len) % bn_v k.n
let bn_mont_ctx_inv (#t: limb_t) (k: bn_mont_ctx t) =
false
null
false
bn_v k.n < pow2 (bits t * k.len) /\ bn_mont_ctx_pre k.n /\ (1 + bn_v k.n * v k.mu) % pow2 (bits t) == 0 /\ bn_v k.r2 == pow2 ((2 * bits t) * k.len) % bn_v k.n
{ "checked_file": "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.MontArithmetic.fsti" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Prims.pow2", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_pre", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__mu", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__r2", "Prims.logical" ]
[]
module Hacl.Spec.Bignum.MontArithmetic open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module Euclid = FStar.Math.Euclid module M = Hacl.Spec.Montgomery.Lemmas module BN = Hacl.Spec.Bignum #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_mont_ctx_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) = 1 < bn_v n /\ bn_v n % 2 = 1 inline_for_extraction class bn_mont_ctx (t:limb_t) = { len: BN.bn_len t; n: lbignum t len; mu: limb t; r2: lbignum t len }
false
false
Hacl.Spec.Bignum.MontArithmetic.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mont_ctx_inv : k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
[]
Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
{ "end_col": 51, "end_line": 33, "start_col": 2, "start_line": 30 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "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 bn_field_exp_st (t:limb_t) (k:bn_mont_ctx t{bn_mont_ctx_inv k}) = aM:bn_mont_nat k -> bBits:size_nat -> b:lbignum t (blocks0 bBits (bits t)) -> Pure (bn_mont_nat k) (requires bn_v b < pow2 bBits) (ensures fun cM -> bn_v (bn_from_field k cM) == Lib.NatMod.pow_mod #(bn_v k.n) (bn_v (bn_from_field k aM)) (bn_v b))
let bn_field_exp_st (t: limb_t) (k: bn_mont_ctx t {bn_mont_ctx_inv k}) =
false
null
false
aM: bn_mont_nat k -> bBits: size_nat -> b: lbignum t (blocks0 bBits (bits t)) -> Pure (bn_mont_nat k) (requires bn_v b < pow2 bBits) (ensures fun cM -> bn_v (bn_from_field k cM) == Lib.NatMod.pow_mod #(bn_v k.n) (bn_v (bn_from_field k aM)) (bn_v b))
{ "checked_file": "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.MontArithmetic.fsti" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_nat", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Prims.eq2", "Prims.nat", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Spec.Bignum.MontArithmetic.bn_from_field", "Lib.NatMod.pow_mod", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n" ]
[]
module Hacl.Spec.Bignum.MontArithmetic open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module Euclid = FStar.Math.Euclid module M = Hacl.Spec.Montgomery.Lemmas module BN = Hacl.Spec.Bignum #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_mont_ctx_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) = 1 < bn_v n /\ bn_v n % 2 = 1 inline_for_extraction class bn_mont_ctx (t:limb_t) = { len: BN.bn_len t; n: lbignum t len; mu: limb t; r2: lbignum t len } let bn_mont_ctx_inv (#t:limb_t) (k:bn_mont_ctx t) = bn_v k.n < pow2 (bits t * k.len) /\ bn_mont_ctx_pre k.n /\ (1 + bn_v k.n * v k.mu) % pow2 (bits t) == 0 /\ bn_v k.r2 == pow2 (2 * bits t * k.len) % bn_v k.n let bn_mont_nat (#t:limb_t) (k:bn_mont_ctx t) = x:lbignum t k.len{bn_v x < bn_v k.n} val bn_field_get_len: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> BN.bn_len t val bn_field_check_modulus: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> res:bool{res <==> bn_mont_ctx_pre n} // computes the Montgomery constants r2 and mu val bn_field_init: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> Pure (bn_mont_ctx t) (requires bn_mont_ctx_pre n) (ensures fun k -> bn_mont_ctx_inv k /\ k.n == n /\ k.len == len) val bn_to_field: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> a:lbignum t k.len -> Pure (bn_mont_nat k) (requires True) (ensures fun aM -> bn_v aM == M.to_mont (bits t) k.len (bn_v k.n) (v k.mu) (bn_v a)) val bn_from_field: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> aM:bn_mont_nat k -> Pure (lbignum t k.len) (requires True) (ensures fun a -> bn_v a < bn_v k.n /\ bn_v a == M.from_mont (bits t) k.len (bn_v k.n) (v k.mu) (bn_v aM)) val bn_from_to_field_lemma: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> a:lbignum t k.len -> Lemma (bn_v (bn_from_field k (bn_to_field k a)) == bn_v a % bn_v k.n) val bn_field_add: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> aM:bn_mont_nat k -> bM:bn_mont_nat k -> Pure (bn_mont_nat k) (requires True) (ensures fun cM -> bn_v (bn_from_field k cM) == (bn_v (bn_from_field k aM) + bn_v (bn_from_field k bM)) % bn_v k.n) val bn_field_sub: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> aM:bn_mont_nat k -> bM:bn_mont_nat k -> Pure (bn_mont_nat k) (requires True) (ensures fun cM -> bn_v (bn_from_field k cM) == (bn_v (bn_from_field k aM) - bn_v (bn_from_field k bM)) % bn_v k.n) val bn_field_mul: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> aM:bn_mont_nat k -> bM:bn_mont_nat k -> Pure (bn_mont_nat k) (requires True) (ensures fun cM -> bn_v (bn_from_field k cM) == bn_v (bn_from_field k aM) * bn_v (bn_from_field k bM) % bn_v k.n) val bn_field_sqr: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> aM:bn_mont_nat k -> Pure (bn_mont_nat k) (requires True) (ensures fun cM -> bn_v (bn_from_field k cM) == bn_v (bn_from_field k aM) * bn_v (bn_from_field k aM) % bn_v k.n) val bn_field_one: #t:limb_t -> k:bn_mont_ctx t{bn_mont_ctx_inv k} -> Pure (bn_mont_nat k) (requires True) (ensures fun oneM -> bn_v (bn_from_field k oneM) == 1) noextract
false
false
Hacl.Spec.Bignum.MontArithmetic.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_field_exp_st : t: Hacl.Spec.Bignum.Definitions.limb_t -> k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t {Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv k} -> Type0
[]
Hacl.Spec.Bignum.MontArithmetic.bn_field_exp_st
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Spec.Bignum.Definitions.limb_t -> k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t {Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv k} -> Type0
{ "end_col": 101, "end_line": 115, "start_col": 4, "start_line": 109 }
Prims.Tot
val table_inv_w5:BE.table_inv_t U64 15ul 32ul
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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 table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len
val table_inv_w5:BE.table_inv_t U64 15ul 32ul let table_inv_w5:BE.table_inv_t U64 15ul 32ul =
false
null
false
[@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let l = 5ul in [@@ inline_let ]let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.table_inv_precomp", "Lib.IntTypes.U64", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.pow2", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.K256.Group.mk_k256_concrete_ops" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val table_inv_w5:BE.table_inv_t U64 15ul 32ul
[]
Hacl.Impl.K256.PointMul.table_inv_w5
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (FStar.UInt32.uint_to_t 15 <: FStar.UInt32.t) (FStar.UInt32.uint_to_t 32 <: FStar.UInt32.t)
{ "end_col": 48, "end_line": 48, "start_col": 2, "start_line": 42 }
Prims.Tot
val table_inv_w4:BE.table_inv_t U64 15ul 16ul
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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 table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len
val table_inv_w4:BE.table_inv_t U64 15ul 16ul let table_inv_w4:BE.table_inv_t U64 15ul 16ul =
false
null
false
[@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.table_inv_precomp", "Lib.IntTypes.U64", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.K256.Group.mk_k256_concrete_ops" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val table_inv_w4:BE.table_inv_t U64 15ul 16ul
[]
Hacl.Impl.K256.PointMul.table_inv_w4
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (FStar.UInt32.uint_to_t 15 <: FStar.UInt32.t) (FStar.UInt32.uint_to_t 16 <: FStar.UInt32.t)
{ "end_col": 48, "end_line": 37, "start_col": 2, "start_line": 32 }
FStar.Pervasives.Lemma
val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b)))
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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_exp_four_fw_local b = let cm = S.mk_k256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b))
val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b =
false
null
true
let cm = S.mk_k256_comm_monoid in let b0, b1, b2, b3 = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b))
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.U64", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Spec.K256.PointOps.q", "Prims.int", "Prims._assert", "Prims.eq2", "Spec.K256.PointOps.aff_point", "Spec.K256.PointOps.to_aff_point", "Spec.K256.point_mul_g", "Lib.Exponentiation.Definition.pow", "Hacl.K256.PrecompTable.g_aff", "Prims.unit", "Lib.Exponentiation.exp_fw_lemma", "Spec.Exponentiation.exp_fw_lemma", "Spec.K256.PointOps.proj_point", "Spec.K256.mk_k256_concrete_ops", "Spec.K256.PointOps.g", "Hacl.Spec.PrecompBaseTable256.lemma_point_mul_base_precomp4", "Hacl.Spec.PrecompBaseTable256.exp_as_exp_four_nat256_precomp", "Lib.Exponentiation.exp_four_fw", "Hacl.K256.PrecompTable.g_pow2_64", "Hacl.K256.PrecompTable.g_pow2_128", "Hacl.K256.PrecompTable.g_pow2_192", "FStar.Pervasives.Native.tuple4", "Hacl.Spec.PrecompBaseTable256.decompose_nat256_as_four_u64", "Lib.Exponentiation.Definition.comm_monoid", "Spec.K256.mk_k256_comm_monoid" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b)))
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b)))
[]
Hacl.Impl.K256.PointMul.lemma_exp_four_fw_local
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum Lib.IntTypes.U64 4 {Hacl.Spec.Bignum.Definitions.bn_v b < Spec.K256.PointOps.q} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.PrecompBaseTable256.decompose_nat256_as_four_u64 (Hacl.Spec.Bignum.Definitions.bn_v b) in (let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ b0 b1 b2 b3 = _ in Lib.Exponentiation.exp_four_fw Spec.K256.mk_k256_comm_monoid Hacl.K256.PrecompTable.g_aff 64 b0 Hacl.K256.PrecompTable.g_pow2_64 b1 Hacl.K256.PrecompTable.g_pow2_128 b2 Hacl.K256.PrecompTable.g_pow2_192 b3 4 == Spec.K256.PointOps.to_aff_point (Spec.K256.point_mul_g (Hacl.Spec.Bignum.Definitions.bn_v b ))) <: Type0))
{ "end_col": 84, "end_line": 159, "start_col": 31, "start_line": 150 }
FStar.HyperStack.ST.Stack
val point_mul: out:point -> scalar:qelem -> q:point -> Stack unit (requires fun h -> live h out /\ live h scalar /\ live h q /\ disjoint out q /\ disjoint out scalar /\ disjoint q scalar /\ point_inv h q /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul (qas_nat h0 scalar) (point_eval h0 q)))
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out
val point_mul: out:point -> scalar:qelem -> q:point -> Stack unit (requires fun h -> live h out /\ live h scalar /\ live h q /\ disjoint out q /\ disjoint out scalar /\ disjoint q scalar /\ point_inv h q /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul (qas_nat h0 scalar) (point_eval h0 q))) let point_mul out scalar q =
true
null
false
let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "Hacl.Impl.Exponentiation.lexp_fw_consttime", "Lib.IntTypes.U64", "FStar.UInt32.__uint_to_t", "Hacl.Impl.K256.Group.mk_k256_concrete_ops", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Prims.unit", "Spec.Exponentiation.exp_fw_lemma", "Spec.K256.PointOps.proj_point", "Spec.K256.mk_k256_concrete_ops", "Hacl.Impl.K256.Point.point_eval", "Hacl.K256.Scalar.qas_nat", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul: out:point -> scalar:qelem -> q:point -> Stack unit (requires fun h -> live h out /\ live h scalar /\ live h q /\ disjoint out q /\ disjoint out scalar /\ disjoint q scalar /\ point_inv h q /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul (qas_nat h0 scalar) (point_eval h0 q)))
[]
Hacl.Impl.K256.PointMul.point_mul
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.K256.Point.point -> scalar: Hacl.K256.Scalar.qelem -> q: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 93, "end_line": 54, "start_col": 28, "start_line": 51 }
Prims.Tot
val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul)
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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 precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp
val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) let precomp_get_consttime ctx a table bits_l tmp =
false
null
false
[@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ "total" ]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.__uint_to_t", "FStar.Ghost.erased", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.clbuffer", "Lib.IntTypes.op_Star_Bang", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Hacl.Impl.Exponentiation.lprecomp_get_consttime", "Prims.unit", "FStar.UInt32.t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.K256.Group.mk_k256_concrete_ops" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline]
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul)
[]
Hacl.Impl.K256.PointMul.precomp_get_consttime
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Exponentiation.pow_a_to_small_b_st Lib.IntTypes.U64 15ul 0ul Hacl.Impl.K256.Group.mk_k256_concrete_ops 4ul 16ul (Hacl.Impl.Exponentiation.table_inv_precomp 15ul 0ul Hacl.Impl.K256.Group.mk_k256_concrete_ops 4ul 16ul)
{ "end_col": 76, "end_line": 67, "start_col": 2, "start_line": 61 }
FStar.HyperStack.ST.Stack
val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in [@inline_let] let bLen = 4ul in [@inline_let] let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q1) 256 (qas_nat h0 scalar1) (point_eval h0 q2) (qas_nat h0 scalar2) 5
val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2))) let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 =
true
null
false
[@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let l = 5ul in [@@ inline_let ]let table_len = 32ul in [@@ inline_let ]let bLen = 4ul in [@@ inline_let ]let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q1) 256 (qas_nat h0 scalar1) (point_eval h0 q2) (qas_nat h0 scalar2) 5
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Spec.Exponentiation.exp_double_fw_lemma", "Spec.K256.PointOps.proj_point", "Spec.K256.mk_k256_concrete_ops", "Hacl.Impl.K256.Point.point_eval", "Hacl.K256.Scalar.qas_nat", "Prims.unit", "Hacl.Impl.MultiExponentiation.mk_lexp_double_fw_tables", "Lib.IntTypes.U64", "Hacl.Impl.K256.PointMul.table_inv_w5", "Hacl.Impl.Exponentiation.lprecomp_get_vartime", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.Buffer.to_const", "Lib.Buffer.CONST", "Hacl.K256.PrecompTable.precomp_basepoint_table_w5", "Prims._assert", "Lib.Buffer.as_seq", "Hacl.K256.PrecompTable.precomp_basepoint_table_lemma_w5", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.recall_contents", "Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w5", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Prims.pow2", "Lib.IntTypes.v", "FStar.UInt32.t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.K256.Group.mk_k256_concrete_ops" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_k256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline] let point_mul_g out scalar = push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame () //------------------------- inline_for_extraction noextract val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
[]
Hacl.Impl.K256.PointMul.point_mul_g_double_vartime_noalloc
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.K256.Point.point -> scalar1: Hacl.K256.Scalar.qelem -> q1: Hacl.Impl.K256.Point.point -> scalar2: Hacl.K256.Scalar.qelem -> q2: Hacl.Impl.K256.Point.point -> table2: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (32ul *! 15ul) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 45, "end_line": 230, "start_col": 2, "start_line": 205 }
FStar.HyperStack.ST.Stack
val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4))
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out
val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 =
true
null
false
[@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in [@@ inline_let ]let bLen = 1ul in [@@ inline_let ]let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "Hacl.Impl.MultiExponentiation.mk_lexp_four_fw_tables", "Lib.IntTypes.U64", "Hacl.Impl.K256.PointMul.table_inv_w4", "Hacl.Impl.K256.PointMul.precomp_get_consttime", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Lib.Buffer.to_const", "Lib.Buffer.CONST", "Hacl.K256.PrecompTable.precomp_basepoint_table_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_128_table_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_192_table_w4", "Prims.unit", "Hacl.Spec.PrecompBaseTable256.lemma_decompose_nat256_as_four_u64_lbignum", "Lib.Buffer.as_seq", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Prims._assert", "Hacl.K256.PrecompTable.precomp_g_pow2_192_table_lemma_w4", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.recall_contents", "Hacl.K256.PrecompTable.precomp_g_pow2_192_table_lseq_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_128_table_lemma_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_128_table_lseq_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lemma_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "Hacl.K256.PrecompTable.precomp_basepoint_table_lemma_w4", "Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w4", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.K256.Group.mk_k256_concrete_ops" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar))
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4))
[]
Hacl.Impl.K256.PointMul.point_mul_g_noalloc
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.K256.Point.point -> scalar: Hacl.K256.Scalar.qelem -> q1: Hacl.Impl.K256.Point.point -> q2: Hacl.Impl.K256.Point.point -> q3: Hacl.Impl.K256.Point.point -> q4: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 7, "end_line": 142, "start_col": 2, "start_line": 96 }
FStar.HyperStack.ST.Stack
val point_mul_g: out:point -> scalar:qelem -> Stack unit (requires fun h -> live h scalar /\ live h out /\ disjoint out scalar /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_g (qas_nat h0 scalar)))
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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_mul_g out scalar = push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame ()
val point_mul_g: out:point -> scalar:qelem -> Stack unit (requires fun h -> live h scalar /\ live h out /\ disjoint out scalar /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_g (qas_nat h0 scalar))) let point_mul_g out scalar =
true
null
false
push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame ()
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.K256.PointMul.lemma_exp_four_fw_local", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.K256.Scalar.qnlimb", "Hacl.Impl.K256.PointMul.point_mul_g_noalloc", "Hacl.K256.PrecompTable.proj_g_pow2_192_lseq_lemma", "Hacl.K256.PrecompTable.proj_g_pow2_128_lseq_lemma", "Hacl.K256.PrecompTable.proj_g_pow2_64_lseq_lemma", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Hacl.K256.PrecompTable.mk_proj_g_pow2_192", "Lib.Buffer.lbuffer", "FStar.UInt32.__uint_to_t", "Hacl.K256.PrecompTable.mk_proj_g_pow2_128", "Hacl.K256.PrecompTable.mk_proj_g_pow2_64", "Hacl.Impl.K256.Point.make_g", "Lib.Buffer.create", "Lib.IntTypes.u64", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_k256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline]
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul_g: out:point -> scalar:qelem -> Stack unit (requires fun h -> live h scalar /\ live h out /\ disjoint out scalar /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_g (qas_nat h0 scalar)))
[]
Hacl.Impl.K256.PointMul.point_mul_g
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.K256.Point.point -> scalar: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 176, "start_col": 2, "start_line": 164 }
FStar.HyperStack.ST.Stack
val point_mul_g_double_vartime: out:point -> scalar1:qelem -> scalar2:qelem -> q2:point -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h scalar2 /\ live h q2 /\ disjoint q2 out /\ disjoint out scalar1 /\ disjoint out scalar2 /\ point_inv h q2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "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_mul_g_double_vartime out scalar1 scalar2 q2 = push_frame (); [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let table_len = 32ul in assert_norm (pow2 5 == v table_len); let q1 = create 15ul (u64 0) in make_g q1; let table2 = create (table_len *! len) (u64 0) in PT.lprecomp_table len ctx_len k (null uint64) q2 table_len table2; let h = ST.get () in assert (table_inv_w5 (as_seq h q2) (as_seq h table2)); point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2; pop_frame ()
val point_mul_g_double_vartime: out:point -> scalar1:qelem -> scalar2:qelem -> q2:point -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h scalar2 /\ live h q2 /\ disjoint q2 out /\ disjoint out scalar1 /\ disjoint out scalar2 /\ point_inv h q2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2))) let point_mul_g_double_vartime out scalar1 scalar2 q2 =
true
null
false
push_frame (); [@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let table_len = 32ul in assert_norm (pow2 5 == v table_len); let q1 = create 15ul (u64 0) in make_g q1; let table2 = create (table_len *! len) (u64 0) in PT.lprecomp_table len ctx_len k (null uint64) q2 table_len table2; let h = ST.get () in assert (table_inv_w5 (as_seq h q2) (as_seq h table2)); point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2; pop_frame ()
{ "checked_file": "Hacl.Impl.K256.PointMul.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.K256.PointMul.point_mul_g_double_vartime_noalloc", "Prims._assert", "Hacl.Impl.K256.PointMul.table_inv_w5", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.PrecompTable.lprecomp_table", "Lib.Buffer.null", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.mul", "Lib.Buffer.create", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "Hacl.Impl.K256.Point.make_g", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Prims.pow2", "Lib.IntTypes.v", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.K256.Group.mk_k256_concrete_ops", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_k256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline] let point_mul_g out scalar = push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame () //------------------------- inline_for_extraction noextract val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2))) let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in [@inline_let] let bLen = 4ul in [@inline_let] let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q1) 256 (qas_nat h0 scalar1) (point_eval h0 q2) (qas_nat h0 scalar2) 5 [@CInline]
false
false
Hacl.Impl.K256.PointMul.fst
{ "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul_g_double_vartime: out:point -> scalar1:qelem -> scalar2:qelem -> q2:point -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h scalar2 /\ live h q2 /\ disjoint q2 out /\ disjoint out scalar1 /\ disjoint out scalar2 /\ point_inv h q2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
[]
Hacl.Impl.K256.PointMul.point_mul_g_double_vartime
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.K256.Point.point -> scalar1: Hacl.K256.Scalar.qelem -> scalar2: Hacl.K256.Scalar.qelem -> q2: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 250, "start_col": 2, "start_line": 235 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 defined r = ~(Unknown? r)
let defined r =
false
null
false
~(Unknown? r)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq._cmpres", "Prims.l_not", "Prims.b2t", "FStar.Reflection.V2.TermEq.uu___is_Unknown", "Prims.logical" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2
false
true
FStar.Reflection.V2.TermEq.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 defined : r: FStar.Reflection.V2.TermEq._cmpres -> Prims.logical
[]
FStar.Reflection.V2.TermEq.defined
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.Reflection.V2.TermEq._cmpres -> Prims.logical
{ "end_col": 29, "end_line": 381, "start_col": 16, "start_line": 381 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y))
let def2 f l1 l2 =
false
null
false
(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y))
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq._cmpres", "Prims.list", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "FStar.List.Tot.Base.memP", "FStar.Reflection.V2.TermEq.defined", "Prims.logical" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r)
false
false
FStar.Reflection.V2.TermEq.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 def2 : f: (_: _ -> _: _ -> FStar.Reflection.V2.TermEq._cmpres) -> l1: Prims.list _ -> l2: Prims.list _ -> Prims.logical
[]
FStar.Reflection.V2.TermEq.def2
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: _ -> _: _ -> FStar.Reflection.V2.TermEq._cmpres) -> l1: Prims.list _ -> l2: Prims.list _ -> Prims.logical
{ "end_col": 78, "end_line": 383, "start_col": 18, "start_line": 383 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 faithful_universe = t:universe{faithful_univ t}
let faithful_universe =
false
null
false
t: universe{faithful_univ t}
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.faithful_univ" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> () #pop-options let faithful_term = t:term{faithful t} (* A conservative version: works on all terms, returns `true` if they are guaranteed to be equal. *) let term_eq (t1 t2 : term) : (b:bool{b ==> t1 == t2}) = Eq? (term_cmp t1 t2) (* A fully decidable version, for faithful terms. *) let term_eq_dec (t1 t2 : faithful_term) : (b:bool{b <==> t1 == t2}) = faithful_lemma t1 t2; Eq? (term_cmp t1 t2)
false
true
FStar.Reflection.V2.TermEq.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 faithful_universe : Type0
[]
FStar.Reflection.V2.TermEq.faithful_universe
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type0
{ "end_col": 51, "end_line": 828, "start_col": 24, "start_line": 828 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 faithful_term = t:term{faithful t}
let faithful_term =
false
null
false
t: term{faithful t}
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.term", "FStar.Reflection.V2.TermEq.faithful" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> () #pop-options
false
true
FStar.Reflection.V2.TermEq.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 faithful_term : Type0
[]
FStar.Reflection.V2.TermEq.faithful_term
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type0
{ "end_col": 38, "end_line": 815, "start_col": 20, "start_line": 815 }
FStar.Pervasives.Lemma
val memP_dec (#a: _) (x: a) (l: list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)]
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys
val memP_dec (#a: _) (x: a) (l: list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] let rec memP_dec #a (x: a) (l: list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] =
false
null
true
match l with | [] -> () | y :: ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.StrongExcludedMiddle.strong_excluded_middle", "Prims.eq2", "Prims.bool", "FStar.Reflection.V2.TermEq.memP_dec", "Prims.unit", "FStar.List.Tot.Base.memP", "Prims.squash", "Prims.precedes", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l)
false
false
FStar.Reflection.V2.TermEq.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 memP_dec (#a: _) (x: a) (l: list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)]
[ "recursion" ]
FStar.Reflection.V2.TermEq.memP_dec
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> l: Prims.list a -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.memP x l) (ensures x << l) [SMTPat (FStar.List.Tot.Base.memP x l)]
{ "end_col": 88, "end_line": 65, "start_col": 4, "start_line": 62 }
Prims.Tot
val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq
val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 =
false
null
false
match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq.comparator_for", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.Eq", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a)
false
false
FStar.Reflection.V2.TermEq.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 opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a)
[]
FStar.Reflection.V2.TermEq.opt_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
cmp: FStar.Reflection.V2.TermEq.comparator_for a -> FStar.Reflection.V2.TermEq.comparator_for (FStar.Pervasives.Native.option a)
{ "end_col": 12, "end_line": 129, "start_col": 2, "start_line": 126 }
Prims.Tot
val allP0 (#a: _) (pred: (a -> Type0)) (l: list a) : Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs
val allP0 (#a: _) (pred: (a -> Type0)) (l: list a) : Type0 let rec allP0 #a (pred: (a -> Type0)) (l: list a) : Type0 =
false
null
false
match l with | [] -> True | x :: xs -> pred x /\ allP0 pred xs
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "Prims.list", "Prims.l_True", "Prims.l_and", "FStar.Reflection.V2.TermEq.allP0" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *)
false
false
FStar.Reflection.V2.TermEq.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 allP0 (#a: _) (pred: (a -> Type0)) (l: list a) : Type0
[ "recursion" ]
FStar.Reflection.V2.TermEq.allP0
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
pred: (_: a -> Type0) -> l: Prims.list a -> Type0
{ "end_col": 36, "end_line": 23, "start_col": 2, "start_line": 21 }
Prims.Tot
val ctxu_cmp : comparator_for ctx_uvar_and_subst
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 ctxu_cmp _ _ = Unknown
val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ =
false
null
false
Unknown
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.ctx_uvar_and_subst", "FStar.Reflection.V2.TermEq.Unknown", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *)
false
true
FStar.Reflection.V2.TermEq.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 ctxu_cmp : comparator_for ctx_uvar_and_subst
[]
FStar.Reflection.V2.TermEq.ctxu_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Reflection.Types.ctx_uvar_and_subst
{ "end_col": 26, "end_line": 230, "start_col": 19, "start_line": 230 }
Prims.Tot
val fv_cmp : comparator_for fv
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq
val fv_cmp : comparator_for fv let fv_cmp f1 f2 =
false
null
false
pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.fv", "Prims.op_Equality", "FStar.Reflection.Types.name", "FStar.Reflection.V2.TermEq.Eq", "Prims.bool", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres", "FStar.Reflection.V2.Builtins.inspect_fv", "Prims.unit", "FStar.Reflection.V2.Builtins.pack_inspect_fv" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv
false
true
FStar.Reflection.V2.TermEq.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 fv_cmp : comparator_for fv
[]
FStar.Reflection.V2.TermEq.fv_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Reflection.Types.fv
{ "end_col": 31, "end_line": 122, "start_col": 4, "start_line": 118 }
Prims.Tot
val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2
val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) =
false
null
false
cmpa a1 a2 &&& cmpb b1 b2
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq.comparator_for", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b)
false
false
FStar.Reflection.V2.TermEq.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 pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b)
[]
FStar.Reflection.V2.TermEq.pair_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
cmpa: FStar.Reflection.V2.TermEq.comparator_for a -> cmpb: FStar.Reflection.V2.TermEq.comparator_for b -> FStar.Reflection.V2.TermEq.comparator_for (a * b)
{ "end_col": 27, "end_line": 140, "start_col": 2, "start_line": 140 }
FStar.Pervasives.Lemma
val memP_allP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type)) (x: a) (l: list a {l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)]
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys
val memP_allP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type)) (x: a) (l: list a {l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] let rec memP_allP #a #b (top: b) (pred: (x: a{x << top} -> Type)) (x: a) (l: list a {l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] =
false
null
true
match l with | [] -> () | y :: ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "Prims.precedes", "Prims.list", "FStar.StrongExcludedMiddle.strong_excluded_middle", "Prims.eq2", "Prims.bool", "FStar.Reflection.V2.TermEq.memP_allP", "Prims.unit", "Prims.l_and", "FStar.Reflection.V2.TermEq.allP", "FStar.List.Tot.Base.memP", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x)
false
false
FStar.Reflection.V2.TermEq.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 memP_allP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type)) (x: a) (l: list a {l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)]
[ "recursion" ]
FStar.Reflection.V2.TermEq.memP_allP
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
top: b -> pred: (x: a{x << top} -> Type0) -> x: a -> l: Prims.list a {l << top} -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.allP top pred l /\ FStar.List.Tot.Base.memP x l) (ensures x << top /\ pred x) [SMTPat (FStar.Reflection.V2.TermEq.allP top pred l); SMTPat (FStar.List.Tot.Base.memP x l)]
{ "end_col": 98, "end_line": 47, "start_col": 4, "start_line": 44 }
Prims.Tot
val bv_cmp : comparator_for bv
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq
val bv_cmp : comparator_for bv let bv_cmp x1 x2 =
false
null
false
let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.bv", "Prims.op_Equality", "Prims.nat", "FStar.Reflection.V2.Data.__proj__Mkbv_view__item__index", "FStar.Reflection.V2.TermEq.Eq", "Prims.bool", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres", "Prims.unit", "FStar.Sealed.sealed_singl", "FStar.Reflection.Types.typ", "FStar.Reflection.V2.Data.__proj__Mkbv_view__item__sort", "FStar.Reflection.V2.Builtins.pack_inspect_bv", "FStar.Reflection.V2.Data.bv_view", "Prims.precedes", "FStar.Reflection.V2.Builtins.inspect_bv" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown
false
true
FStar.Reflection.V2.TermEq.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 bv_cmp : comparator_for bv
[]
FStar.Reflection.V2.TermEq.bv_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Reflection.Types.bv
{ "end_col": 41, "end_line": 105, "start_col": 18, "start_line": 99 }
Prims.Tot
val allP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (l: list a {l << top \/ l === top}) : Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs
val allP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (l: list a {l << top \/ l === top}) : Type0 let rec allP #a #b (top: b) (pred: (x: a{x << top} -> Type0)) (l: list a {l << top \/ l === top}) : Type0 =
false
null
false
match l with | [] -> True | x :: xs -> pred x /\ allP top pred xs
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "Prims.precedes", "Prims.list", "Prims.l_or", "Prims.op_Equals_Equals_Equals", "Prims.l_True", "Prims.l_and", "FStar.Reflection.V2.TermEq.allP" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs
false
false
FStar.Reflection.V2.TermEq.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 allP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (l: list a {l << top \/ l === top}) : Type0
[ "recursion" ]
FStar.Reflection.V2.TermEq.allP
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
top: b -> pred: (x: a{x << top} -> Type0) -> l: Prims.list a {l << top \/ l === top} -> Type0
{ "end_col": 39, "end_line": 28, "start_col": 2, "start_line": 26 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True
let valid #t (c: _cmpres) (x: t) (y: t) =
false
null
false
match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq._cmpres", "Prims.eq2", "Prims.l_not", "Prims.l_True", "Prims.logical" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres?
false
false
FStar.Reflection.V2.TermEq.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 valid : c: FStar.Reflection.V2.TermEq._cmpres -> x: t -> y: t -> Prims.logical
[]
FStar.Reflection.V2.TermEq.valid
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
c: FStar.Reflection.V2.TermEq._cmpres -> x: t -> y: t -> Prims.logical
{ "end_col": 19, "end_line": 82, "start_col": 2, "start_line": 79 }
Prims.Tot
val eq_cmp : #a:eqtype -> comparator_for a
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 eq_cmp x y = if x = y then Eq else Neq
val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y =
false
null
false
if x = y then Eq else Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "Prims.eqtype", "Prims.op_Equality", "FStar.Reflection.V2.TermEq.Eq", "Prims.bool", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq
false
false
FStar.Reflection.V2.TermEq.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 eq_cmp : #a:eqtype -> comparator_for a
[]
FStar.Reflection.V2.TermEq.eq_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for a
{ "end_col": 42, "end_line": 183, "start_col": 17, "start_line": 183 }
Prims.Tot
val univ_eq (u1 u2: universe) : (b: bool{b ==> u1 == u2})
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 univ_eq (u1 u2 : universe) : (b:bool{b ==> u1 == u2}) = Eq? (univ_cmp u1 u2)
val univ_eq (u1 u2: universe) : (b: bool{b ==> u1 == u2}) let univ_eq (u1 u2: universe) : (b: bool{b ==> u1 == u2}) =
false
null
false
Eq? (univ_cmp u1 u2)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.uu___is_Eq", "FStar.Reflection.V2.TermEq.univ_cmp", "Prims.bool", "Prims.l_imp", "Prims.b2t", "Prims.eq2" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> () #pop-options let faithful_term = t:term{faithful t} (* A conservative version: works on all terms, returns `true` if they are guaranteed to be equal. *) let term_eq (t1 t2 : term) : (b:bool{b ==> t1 == t2}) = Eq? (term_cmp t1 t2) (* A fully decidable version, for faithful terms. *) let term_eq_dec (t1 t2 : faithful_term) : (b:bool{b <==> t1 == t2}) = faithful_lemma t1 t2; Eq? (term_cmp t1 t2) (* Idem for universes *) let faithful_universe = t:universe{faithful_univ t}
false
false
FStar.Reflection.V2.TermEq.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 univ_eq (u1 u2: universe) : (b: bool{b ==> u1 == u2})
[]
FStar.Reflection.V2.TermEq.univ_eq
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
u1: FStar.Reflection.Types.universe -> u2: FStar.Reflection.Types.universe -> b: Prims.bool{b ==> u1 == u2}
{ "end_col": 22, "end_line": 830, "start_col": 2, "start_line": 830 }
Prims.Tot
val ident_cmp : comparator_for ident
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2)
val ident_cmp : comparator_for ident let ident_cmp i1 i2 =
false
null
false
let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.ident", "FStar.Reflection.V2.TermEq.eq_cmp", "Prims.string", "FStar.Pervasives.Native.fst", "FStar.Range.range", "Prims.unit", "FStar.Sealed.sealed_singl", "FStar.Range.__range", "FStar.Pervasives.Native.snd", "FStar.Reflection.V2.Builtins.pack_inspect_ident", "FStar.Reflection.V2.Data.ident_view", "Prims.precedes", "FStar.Reflection.V2.Builtins.inspect_ident", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq
false
true
FStar.Reflection.V2.TermEq.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 ident_cmp : comparator_for ident
[]
FStar.Reflection.V2.TermEq.ident_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Reflection.Types.ident
{ "end_col": 28, "end_line": 197, "start_col": 21, "start_line": 191 }
Prims.Tot
val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq
val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 =
false
null
false
match l1, l2 with | [], [] -> Eq | x :: xs, y :: ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq.comparator_for", "Prims.list", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.Eq", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Reflection.V2.TermEq.list_cmp", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a)
false
false
FStar.Reflection.V2.TermEq.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 list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a)
[ "recursion" ]
FStar.Reflection.V2.TermEq.list_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
cmp: FStar.Reflection.V2.TermEq.comparator_for a -> FStar.Reflection.V2.TermEq.comparator_for (Prims.list a)
{ "end_col": 12, "end_line": 147, "start_col": 2, "start_line": 144 }
Prims.Tot
val univ_eq_dec (u1 u2: faithful_universe) : (b: bool{b <==> u1 == u2})
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 univ_eq_dec (u1 u2 : faithful_universe) : (b:bool{b <==> u1 == u2}) = univ_faithful_lemma u1 u2; Eq? (univ_cmp u1 u2)
val univ_eq_dec (u1 u2: faithful_universe) : (b: bool{b <==> u1 == u2}) let univ_eq_dec (u1 u2: faithful_universe) : (b: bool{b <==> u1 == u2}) =
false
null
false
univ_faithful_lemma u1 u2; Eq? (univ_cmp u1 u2)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq.faithful_universe", "FStar.Reflection.V2.TermEq.uu___is_Eq", "FStar.Reflection.V2.TermEq.univ_cmp", "Prims.unit", "FStar.Reflection.V2.TermEq.univ_faithful_lemma", "Prims.bool", "Prims.l_iff", "Prims.b2t", "Prims.eq2" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> () #pop-options let faithful_term = t:term{faithful t} (* A conservative version: works on all terms, returns `true` if they are guaranteed to be equal. *) let term_eq (t1 t2 : term) : (b:bool{b ==> t1 == t2}) = Eq? (term_cmp t1 t2) (* A fully decidable version, for faithful terms. *) let term_eq_dec (t1 t2 : faithful_term) : (b:bool{b <==> t1 == t2}) = faithful_lemma t1 t2; Eq? (term_cmp t1 t2) (* Idem for universes *) let faithful_universe = t:universe{faithful_univ t} let univ_eq (u1 u2 : universe) : (b:bool{b ==> u1 == u2}) = Eq? (univ_cmp u1 u2)
false
false
FStar.Reflection.V2.TermEq.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 univ_eq_dec (u1 u2: faithful_universe) : (b: bool{b <==> u1 == u2})
[]
FStar.Reflection.V2.TermEq.univ_eq_dec
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
u1: FStar.Reflection.V2.TermEq.faithful_universe -> u2: FStar.Reflection.V2.TermEq.faithful_universe -> b: Prims.bool{b <==> u1 == u2}
{ "end_col": 22, "end_line": 833, "start_col": 2, "start_line": 832 }
Prims.Tot
val univ_cmp : comparator_for universe
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq
val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2: universe) =
false
null
false
pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.universe_view", "FStar.Reflection.V2.TermEq.Eq", "FStar.Reflection.V2.TermEq.univ_cmp", "FStar.Reflection.V2.Data.universes", "FStar.Reflection.V2.TermEq.list_dec_cmp", "Prims.nat", "FStar.Reflection.V2.TermEq.eq_cmp", "FStar.Reflection.Types.univ_name", "FStar.Reflection.V2.TermEq.ident_cmp", "FStar.Reflection.Types.universe_uvar", "FStar.Reflection.V2.TermEq.Unknown", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres", "Prims.precedes", "FStar.Reflection.V2.Builtins.inspect_universe", "Prims.unit", "FStar.Reflection.V2.Builtins.pack_inspect_universe" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe
false
true
FStar.Reflection.V2.TermEq.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 univ_cmp : comparator_for universe
[ "recursion" ]
FStar.Reflection.V2.TermEq.univ_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Reflection.Types.universe
{ "end_col": 12, "end_line": 213, "start_col": 2, "start_line": 201 }
Prims.Tot
val term_eq (t1 t2: term) : (b: bool{b ==> t1 == t2})
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 term_eq (t1 t2 : term) : (b:bool{b ==> t1 == t2}) = Eq? (term_cmp t1 t2)
val term_eq (t1 t2: term) : (b: bool{b ==> t1 == t2}) let term_eq (t1 t2: term) : (b: bool{b ==> t1 == t2}) =
false
null
false
Eq? (term_cmp t1 t2)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.term", "FStar.Reflection.V2.TermEq.uu___is_Eq", "FStar.Reflection.V2.TermEq.term_cmp", "Prims.bool", "Prims.l_imp", "Prims.b2t", "Prims.eq2" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> () #pop-options let faithful_term = t:term{faithful t} (* A conservative version: works on all terms, returns `true` if they are guaranteed to be equal. *)
false
false
FStar.Reflection.V2.TermEq.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 term_eq (t1 t2: term) : (b: bool{b ==> t1 == t2})
[]
FStar.Reflection.V2.TermEq.term_eq
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t1: FStar.Reflection.Types.term -> t2: FStar.Reflection.Types.term -> b: Prims.bool{b ==> t1 == t2}
{ "end_col": 22, "end_line": 820, "start_col": 2, "start_line": 820 }
Prims.Tot
val faithful_univ : universe -> Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us
val faithful_univ : universe -> Type0 let rec faithful_univ (u: universe) =
false
null
false
match inspect_universe u with | Uv_Unif _ -> False | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Reflection.V2.Builtins.inspect_universe", "FStar.Reflection.Types.universe_uvar", "Prims.l_False", "Prims.l_True", "Prims.nat", "FStar.Reflection.Types.univ_name", "FStar.Reflection.V2.TermEq.faithful_univ", "FStar.Reflection.V2.Data.universes", "FStar.Reflection.V2.TermEq.allP" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0
false
true
FStar.Reflection.V2.TermEq.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 faithful_univ : universe -> Type0
[ "recursion" ]
FStar.Reflection.V2.TermEq.faithful_univ
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
u102: FStar.Reflection.Types.universe -> Type0
{ "end_col": 40, "end_line": 412, "start_col": 2, "start_line": 403 }
FStar.Pervasives.Lemma
val faithful_Tv_Match (t sc: term) (o: option match_returns_ascription) (brs: list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs)
val faithful_Tv_Match (t sc: term) (o: option match_returns_ascription) (brs: list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) let faithful_Tv_Match (t sc: term) (o: option match_returns_ascription) (brs: list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) =
false
null
true
assert_norm (faithful t ==> allP t faithful_branch brs)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "FStar.Reflection.Types.term", "FStar.Pervasives.Native.option", "FStar.Reflection.Types.match_returns_ascription", "Prims.list", "FStar.Reflection.V2.Data.branch", "FStar.Pervasives.assert_norm", "Prims.l_imp", "FStar.Reflection.V2.TermEq.faithful", "FStar.Reflection.V2.TermEq.allP", "FStar.Reflection.V2.TermEq.faithful_branch", "Prims.unit", "Prims.l_and", "Prims.eq2", "FStar.Reflection.V2.Data.term_view", "FStar.Reflection.V2.Builtins.inspect_ln", "FStar.Reflection.V2.Data.Tv_Match", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t)
false
false
FStar.Reflection.V2.TermEq.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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val faithful_Tv_Match (t sc: term) (o: option match_returns_ascription) (brs: list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs)
[]
FStar.Reflection.V2.TermEq.faithful_Tv_Match
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Reflection.Types.term -> sc: FStar.Reflection.Types.term -> o: FStar.Pervasives.Native.option FStar.Reflection.Types.match_returns_ascription -> brs: Prims.list FStar.Reflection.V2.Data.branch -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.Builtins.inspect_ln t == FStar.Reflection.V2.Data.Tv_Match sc o brs /\ FStar.Reflection.V2.TermEq.faithful t) (ensures FStar.Reflection.V2.TermEq.allP t FStar.Reflection.V2.TermEq.faithful_branch brs)
{ "end_col": 59, "end_line": 574, "start_col": 4, "start_line": 574 }
FStar.Pervasives.Lemma
val faithful_univ_UvMax (u: universe) (us: list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us)
val faithful_univ_UvMax (u: universe) (us: list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) let faithful_univ_UvMax (u: universe) (us: list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) =
false
null
true
assert_norm (faithful_univ u <==> allP u faithful_univ us)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "FStar.Reflection.Types.universe", "Prims.list", "FStar.Pervasives.assert_norm", "Prims.l_iff", "FStar.Reflection.V2.TermEq.faithful_univ", "FStar.Reflection.V2.TermEq.allP", "Prims.unit", "Prims.l_and", "Prims.eq2", "FStar.Reflection.V2.Data.universe_view", "FStar.Reflection.V2.Builtins.inspect_universe", "FStar.Reflection.V2.Data.Uv_Max", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u)
false
false
FStar.Reflection.V2.TermEq.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 faithful_univ_UvMax (u: universe) (us: list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us)
[]
FStar.Reflection.V2.TermEq.faithful_univ_UvMax
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
u104: FStar.Reflection.Types.universe -> us: Prims.list FStar.Reflection.Types.universe -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.Builtins.inspect_universe u104 == FStar.Reflection.V2.Data.Uv_Max us /\ FStar.Reflection.V2.TermEq.faithful_univ u104) (ensures FStar.Reflection.V2.TermEq.allP u104 FStar.Reflection.V2.TermEq.faithful_univ us)
{ "end_col": 62, "end_line": 417, "start_col": 4, "start_line": 417 }
Prims.Tot
val optP0 (#a: _) (pred: (a -> Type0)) (o: option a) : Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x
val optP0 (#a: _) (pred: (a -> Type0)) (o: option a) : Type0 let optP0 #a (pred: (a -> Type0)) (o: option a) : Type0 =
false
null
false
match o with | None -> True | Some x -> pred x
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.option", "Prims.l_True" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs
false
false
FStar.Reflection.V2.TermEq.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 optP0 (#a: _) (pred: (a -> Type0)) (o: option a) : Type0
[]
FStar.Reflection.V2.TermEq.optP0
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
pred: (_: a -> Type0) -> o: FStar.Pervasives.Native.option a -> Type0
{ "end_col": 20, "end_line": 33, "start_col": 2, "start_line": 31 }
FStar.Pervasives.Lemma
val defined_list (#a: _) (f: comparator_for a) (l1 l2: list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2))
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> ()
val defined_list (#a: _) (f: comparator_for a) (l1 l2: list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) let rec defined_list #a (f: comparator_for a) (l1: list a) (l2: list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) =
false
null
true
match l1, l2 with | [], [] -> () | x :: xs, y :: ys -> defined_list f xs ys | _ -> ()
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "FStar.Reflection.V2.TermEq.comparator_for", "Prims.list", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.defined_list", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Reflection.V2.TermEq.def2", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "FStar.Reflection.V2.TermEq.list_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a)
false
false
FStar.Reflection.V2.TermEq.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 defined_list (#a: _) (f: comparator_for a) (l1 l2: list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2))
[ "recursion" ]
FStar.Reflection.V2.TermEq.defined_list
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: FStar.Reflection.V2.TermEq.comparator_for a -> l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.def2 f l1 l2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.list_cmp f l1 l2))
{ "end_col": 13, "end_line": 390, "start_col": 4, "start_line": 387 }
Prims.Tot
val op_Amp_Amp_Amp (#s: Type u#ss) (#t: Type u#tt) (#x #y: s) (#w #z: t) ($c1: cmpres x y) ($c2: cmpres w z) : cmpres (x, w) (y, z)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown
val op_Amp_Amp_Amp (#s: Type u#ss) (#t: Type u#tt) (#x #y: s) (#w #z: t) ($c1: cmpres x y) ($c2: cmpres w z) : cmpres (x, w) (y, z) let op_Amp_Amp_Amp (#s: Type u#ss) (#t: Type u#tt) (#x #y: s) (#w #z: t) ($c1: cmpres x y) ($c2: cmpres w z) : cmpres (x, w) (y, z) =
false
null
false
match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq.cmpres", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq._cmpres", "FStar.Reflection.V2.TermEq.Eq", "FStar.Reflection.V2.TermEq.Neq", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Unknown" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z)
false
false
FStar.Reflection.V2.TermEq.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 op_Amp_Amp_Amp (#s: Type u#ss) (#t: Type u#tt) (#x #y: s) (#w #z: t) ($c1: cmpres x y) ($c2: cmpres w z) : cmpres (x, w) (y, z)
[]
FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
$c1: FStar.Reflection.V2.TermEq.cmpres x y -> $c2: FStar.Reflection.V2.TermEq.cmpres w z -> FStar.Reflection.V2.TermEq.cmpres (x, w) (y, z)
{ "end_col": 16, "end_line": 96, "start_col": 2, "start_line": 92 }
FStar.Pervasives.Lemma
val univ_eq_UvMax (u1 u2: universe) (us1 us2: list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2)
val univ_eq_UvMax (u1 u2: universe) (us1 us2: list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) let univ_eq_UvMax (u1 u2: universe) (us1 us2: list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) =
false
null
true
assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "FStar.Reflection.Types.universe", "Prims.list", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.Reflection.V2.TermEq._cmpres", "Prims.l_or", "FStar.Reflection.V2.TermEq.valid", "FStar.Reflection.V2.TermEq.univ_cmp", "FStar.Reflection.V2.TermEq.list_dec_cmp", "Prims.unit", "Prims.l_and", "FStar.Reflection.V2.Data.universe_view", "FStar.Reflection.V2.Builtins.inspect_universe", "FStar.Reflection.V2.Data.Uv_Max", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2)
false
false
FStar.Reflection.V2.TermEq.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 univ_eq_UvMax (u1 u2: universe) (us1 us2: list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2)
[]
FStar.Reflection.V2.TermEq.univ_eq_UvMax
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
u1: FStar.Reflection.Types.universe -> u2: FStar.Reflection.Types.universe -> us1: Prims.list FStar.Reflection.Types.universe -> us2: Prims.list FStar.Reflection.Types.universe -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.Builtins.inspect_universe u1 == FStar.Reflection.V2.Data.Uv_Max us1 /\ FStar.Reflection.V2.Builtins.inspect_universe u2 == FStar.Reflection.V2.Data.Uv_Max us2) (ensures FStar.Reflection.V2.TermEq.univ_cmp u1 u2 == FStar.Reflection.V2.TermEq.list_dec_cmp u1 u2 FStar.Reflection.V2.TermEq.univ_cmp us1 us2)
{ "end_col": 71, "end_line": 423, "start_col": 4, "start_line": 423 }
FStar.Pervasives.Lemma
val memP_allP0 (#a: _) (pred: (a -> Type)) (x: a) (l: list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)]
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys
val memP_allP0 (#a: _) (pred: (a -> Type)) (x: a) (l: list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] let rec memP_allP0 #a (pred: (a -> Type)) (x: a) (l: list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] =
false
null
true
match l with | [] -> () | y :: ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.StrongExcludedMiddle.strong_excluded_middle", "Prims.eq2", "Prims.bool", "FStar.Reflection.V2.TermEq.memP_allP0", "Prims.unit", "Prims.l_and", "FStar.Reflection.V2.TermEq.allP0", "FStar.List.Tot.Base.memP", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x)
false
false
FStar.Reflection.V2.TermEq.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 memP_allP0 (#a: _) (pred: (a -> Type)) (x: a) (l: list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)]
[ "recursion" ]
FStar.Reflection.V2.TermEq.memP_allP0
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
pred: (_: a -> Type0) -> x: a -> l: Prims.list a -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.allP0 pred l /\ FStar.List.Tot.Base.memP x l) (ensures pred x) [SMTPat (FStar.Reflection.V2.TermEq.allP0 pred l); SMTPat (FStar.List.Tot.Base.memP x l)]
{ "end_col": 95, "end_line": 56, "start_col": 4, "start_line": 53 }
Prims.Tot
val optP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (o: option a {o << top}) : Type0
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x
val optP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (o: option a {o << top}) : Type0 let optP #a #b (top: b) (pred: (x: a{x << top} -> Type0)) (o: option a {o << top}) : Type0 =
false
null
false
match o with | None -> True | Some x -> pred x
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "Prims.precedes", "FStar.Pervasives.Native.option", "Prims.l_True" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x
false
false
FStar.Reflection.V2.TermEq.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 optP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (o: option a {o << top}) : Type0
[]
FStar.Reflection.V2.TermEq.optP
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
top: b -> pred: (x: a{x << top} -> Type0) -> o: FStar.Pervasives.Native.option a {o << top} -> Type0
{ "end_col": 20, "end_line": 38, "start_col": 2, "start_line": 36 }
Prims.Tot
val namedv_cmp : comparator_for namedv
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq
val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 =
false
null
false
let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.Types.namedv", "Prims.op_Equality", "Prims.nat", "FStar.Reflection.V2.Data.__proj__Mknamedv_view__item__uniq", "FStar.Reflection.V2.TermEq.Eq", "Prims.bool", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres", "Prims.unit", "FStar.Sealed.sealed_singl", "FStar.Reflection.Types.typ", "FStar.Reflection.V2.Data.__proj__Mknamedv_view__item__sort", "FStar.Reflection.V2.Builtins.pack_inspect_namedv", "FStar.Reflection.V2.Data.namedv_view", "Prims.precedes", "FStar.Reflection.V2.Builtins.inspect_namedv" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq
false
true
FStar.Reflection.V2.TermEq.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 namedv_cmp : comparator_for namedv
[]
FStar.Reflection.V2.TermEq.namedv_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Reflection.Types.namedv
{ "end_col": 39, "end_line": 114, "start_col": 22, "start_line": 108 }
Prims.Tot
val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq
val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 =
false
null
false
match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq.comparator_for", "FStar.Pervasives.either", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b)
false
false
FStar.Reflection.V2.TermEq.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 either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b)
[]
FStar.Reflection.V2.TermEq.either_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
cmpa: FStar.Reflection.V2.TermEq.comparator_for a -> cmpb: FStar.Reflection.V2.TermEq.comparator_for b -> FStar.Reflection.V2.TermEq.comparator_for (FStar.Pervasives.either a b)
{ "end_col": 12, "end_line": 136, "start_col": 2, "start_line": 133 }
Prims.Tot
val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq
val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 =
false
null
false
match l1, l2 with | [], [] -> Eq | x :: xs, y :: ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "Prims.l_and", "Prims.precedes", "FStar.Reflection.V2.TermEq.cmpres", "Prims.list", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.Eq", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Reflection.V2.TermEq.list_dec_cmp", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2
false
false
FStar.Reflection.V2.TermEq.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 list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2
[ "recursion" ]
FStar.Reflection.V2.TermEq.list_dec_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
top1: b -> top2: b -> f: (x: a -> y: a{x << top1 /\ y << top2} -> FStar.Reflection.V2.TermEq.cmpres x y) -> l1: Prims.list a -> l2: Prims.list a {l1 << top1 /\ l2 << top2} -> FStar.Reflection.V2.TermEq.cmpres l1 l2
{ "end_col": 12, "end_line": 158, "start_col": 2, "start_line": 155 }
Prims.Tot
val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq
val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 =
false
null
false
match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "Prims.l_and", "Prims.precedes", "FStar.Reflection.V2.TermEq.cmpres", "FStar.Pervasives.either", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "Prims.l_or" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2
false
false
FStar.Reflection.V2.TermEq.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 either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2
[]
FStar.Reflection.V2.TermEq.either_dec_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
top1: c -> top2: c -> cmpa: (x: a -> y: a{x << top1 /\ y << top2} -> FStar.Reflection.V2.TermEq.cmpres x y) -> cmpb: (x: b -> y: b{x << top1 /\ y << top2} -> FStar.Reflection.V2.TermEq.cmpres x y) -> e1: FStar.Pervasives.either a b {e1 << top1} -> e2: FStar.Pervasives.either a b {e2 << top2} -> FStar.Reflection.V2.TermEq.cmpres e1 e2
{ "end_col": 12, "end_line": 180, "start_col": 2, "start_line": 177 }
Prims.Tot
val range_cmp : comparator_for range
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq
val range_cmp : comparator_for range let range_cmp r1 r2 =
false
null
false
Sealed.sealed_singl r1 r2; Eq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Range.range", "FStar.Reflection.V2.TermEq.Eq", "Prims.unit", "FStar.Sealed.sealed_singl", "FStar.Range.__range", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range
false
true
FStar.Reflection.V2.TermEq.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 range_cmp : comparator_for range
[]
FStar.Reflection.V2.TermEq.range_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Range.range
{ "end_col": 4, "end_line": 188, "start_col": 2, "start_line": 187 }
Prims.Tot
val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq
val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 =
false
null
false
match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "Prims.l_and", "Prims.precedes", "FStar.Reflection.V2.TermEq.cmpres", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.Eq", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "Prims.l_or" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2
false
false
FStar.Reflection.V2.TermEq.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 opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2
[]
FStar.Reflection.V2.TermEq.opt_dec_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
top1: b -> top2: b -> f: (x: a -> y: a{x << top1 /\ y << top2} -> FStar.Reflection.V2.TermEq.cmpres x y) -> o1: FStar.Pervasives.Native.option a {o1 << top1} -> o2: FStar.Pervasives.Native.option a {o2 << top2} -> FStar.Reflection.V2.TermEq.cmpres o1 o2
{ "end_col": 12, "end_line": 168, "start_col": 2, "start_line": 165 }
Prims.Tot
val const_cmp : comparator_for vconst
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq
val const_cmp : comparator_for vconst let const_cmp c1 c2 =
false
null
false
match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.Data.vconst", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.Eq", "Prims.int", "FStar.Reflection.V2.TermEq.eq_cmp", "Prims.string", "FStar.Range.range", "FStar.Reflection.V2.TermEq.range_cmp", "FStar.Reflection.Types.name", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst
false
true
FStar.Reflection.V2.TermEq.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 const_cmp : comparator_for vconst
[]
FStar.Reflection.V2.TermEq.const_cmp
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Reflection.V2.TermEq.comparator_for FStar.Reflection.V2.Data.vconst
{ "end_col": 12, "end_line": 226, "start_col": 2, "start_line": 217 }
FStar.Pervasives.Lemma
val faithful_Pat_Cons (p: pattern) (f: fv) (ous: option universes) (subpats: list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats)
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats)
val faithful_Pat_Cons (p: pattern) (f: fv) (ous: option universes) (subpats: list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) let faithful_Pat_Cons (p: pattern) (f: fv) (ous: option universes) (subpats: list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) =
false
null
true
assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "FStar.Reflection.V2.Data.pattern", "FStar.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Reflection.V2.Data.universes", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Pervasives.assert_norm", "Prims.l_imp", "FStar.Reflection.V2.TermEq.faithful_pattern", "FStar.Reflection.V2.TermEq.allP", "FStar.Reflection.V2.TermEq.faithful_pattern_arg", "Prims.unit", "Prims.l_and", "Prims.eq2", "FStar.Reflection.V2.Data.Pat_Cons", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p)
false
false
FStar.Reflection.V2.TermEq.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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val faithful_Pat_Cons (p: pattern) (f: fv) (ous: option universes) (subpats: list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats)
[]
FStar.Reflection.V2.TermEq.faithful_Pat_Cons
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: FStar.Reflection.V2.Data.pattern -> f: FStar.Reflection.Types.fv -> ous: FStar.Pervasives.Native.option FStar.Reflection.V2.Data.universes -> subpats: Prims.list (FStar.Reflection.V2.Data.pattern * Prims.bool) -> FStar.Pervasives.Lemma (requires p == FStar.Reflection.V2.Data.Pat_Cons f ous subpats /\ FStar.Reflection.V2.TermEq.faithful_pattern p) (ensures FStar.Reflection.V2.TermEq.allP p FStar.Reflection.V2.TermEq.faithful_pattern_arg subpats)
{ "end_col": 76, "end_line": 589, "start_col": 4, "start_line": 589 }
FStar.Pervasives.Lemma
val defined_list_dec (#a #b: _) (t1 t2: b) (f: comparator_for a) (l1: list a {l1 << t1}) (l2: list a {l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2))
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> ()
val defined_list_dec (#a #b: _) (t1 t2: b) (f: comparator_for a) (l1: list a {l1 << t1}) (l2: list a {l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) let rec defined_list_dec #a #b (t1: b) (t2: b) (f: comparator_for a) (l1: list a {l1 << t1}) (l2: list a {l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) =
false
null
true
match l1, l2 with | [], [] -> () | x :: xs, y :: ys -> defined_list_dec t1 t2 f xs ys | _ -> ()
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "FStar.Reflection.V2.TermEq.comparator_for", "Prims.list", "Prims.precedes", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.defined_list_dec", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Reflection.V2.TermEq.def2", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "FStar.Reflection.V2.TermEq.list_dec_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2})
false
false
FStar.Reflection.V2.TermEq.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 defined_list_dec (#a #b: _) (t1 t2: b) (f: comparator_for a) (l1: list a {l1 << t1}) (l2: list a {l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2))
[ "recursion" ]
FStar.Reflection.V2.TermEq.defined_list_dec
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t1: b -> t2: b -> f: FStar.Reflection.V2.TermEq.comparator_for a -> l1: Prims.list a {l1 << t1} -> l2: Prims.list a {l2 << t2} -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.def2 f l1 l2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.list_dec_cmp t1 t2 f l1 l2))
{ "end_col": 13, "end_line": 399, "start_col": 4, "start_line": 396 }
Prims.Tot
val term_eq_dec (t1 t2: faithful_term) : (b: bool{b <==> t1 == t2})
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 term_eq_dec (t1 t2 : faithful_term) : (b:bool{b <==> t1 == t2}) = faithful_lemma t1 t2; Eq? (term_cmp t1 t2)
val term_eq_dec (t1 t2: faithful_term) : (b: bool{b <==> t1 == t2}) let term_eq_dec (t1 t2: faithful_term) : (b: bool{b <==> t1 == t2}) =
false
null
false
faithful_lemma t1 t2; Eq? (term_cmp t1 t2)
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "total" ]
[ "FStar.Reflection.V2.TermEq.faithful_term", "FStar.Reflection.V2.TermEq.uu___is_Eq", "FStar.Reflection.V2.TermEq.term_cmp", "Prims.unit", "FStar.Reflection.V2.TermEq.faithful_lemma", "Prims.bool", "Prims.l_iff", "Prims.b2t", "Prims.eq2" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> () #pop-options let faithful_term = t:term{faithful t} (* A conservative version: works on all terms, returns `true` if they are guaranteed to be equal. *) let term_eq (t1 t2 : term) : (b:bool{b ==> t1 == t2}) = Eq? (term_cmp t1 t2) (* A fully decidable version, for faithful terms. *)
false
false
FStar.Reflection.V2.TermEq.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 term_eq_dec (t1 t2: faithful_term) : (b: bool{b <==> t1 == t2})
[]
FStar.Reflection.V2.TermEq.term_eq_dec
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t1: FStar.Reflection.V2.TermEq.faithful_term -> t2: FStar.Reflection.V2.TermEq.faithful_term -> b: Prims.bool{b <==> t1 == t2}
{ "end_col": 22, "end_line": 825, "start_col": 2, "start_line": 824 }
FStar.Pervasives.Lemma
val pat_eq_Pat_Cons (p1 p2: pattern) (f1 f2: fv) (ous1 ous2: option universes) (args1 args2: list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2))
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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 pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2))
val pat_eq_Pat_Cons (p1 p2: pattern) (f1 f2: fv) (ous1 ous2: option universes) (args1 args2: list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let pat_eq_Pat_Cons (p1 p2: pattern) (f1 f2: fv) (ous1 ous2: option universes) (args1 args2: list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) =
false
null
true
assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2))
{ "checked_file": "FStar.Reflection.V2.TermEq.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.Data.fsti.checked", "FStar.Reflection.V2.Builtins.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ "lemma" ]
[ "FStar.Reflection.V2.Data.pattern", "FStar.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Reflection.V2.Data.universes", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.Reflection.V2.TermEq._cmpres", "Prims.l_or", "FStar.Reflection.V2.TermEq.valid", "FStar.Reflection.Types.universe", "Prims.precedes", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.pat_cmp", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Reflection.V2.TermEq.fv_cmp", "FStar.Reflection.V2.TermEq.opt_dec_cmp", "FStar.Reflection.V2.TermEq.list_dec_cmp", "FStar.Reflection.V2.TermEq.univ_cmp", "FStar.Reflection.V2.TermEq.pat_arg_cmp", "Prims.unit", "Prims.l_and", "FStar.Reflection.V2.Data.Pat_Cons", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module FStar.Reflection.V2.TermEq open FStar.Reflection.Types open FStar.Reflection.V2.Data open FStar.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2
false
false
FStar.Reflection.V2.TermEq.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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pat_eq_Pat_Cons (p1 p2: pattern) (f1 f2: fv) (ous1 ous2: option universes) (args1 args2: list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2))
[]
FStar.Reflection.V2.TermEq.pat_eq_Pat_Cons
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p1: FStar.Reflection.V2.Data.pattern -> p2: FStar.Reflection.V2.Data.pattern -> f1: FStar.Reflection.Types.fv -> f2: FStar.Reflection.Types.fv -> ous1: FStar.Pervasives.Native.option FStar.Reflection.V2.Data.universes -> ous2: FStar.Pervasives.Native.option FStar.Reflection.V2.Data.universes -> args1: Prims.list (FStar.Reflection.V2.Data.pattern * Prims.bool) -> args2: Prims.list (FStar.Reflection.V2.Data.pattern * Prims.bool) -> FStar.Pervasives.Lemma (requires p1 == FStar.Reflection.V2.Data.Pat_Cons f1 ous1 args1 /\ p2 == FStar.Reflection.V2.Data.Pat_Cons f2 ous2 args2) (ensures FStar.Reflection.V2.TermEq.pat_cmp p1 p2 == (FStar.Reflection.V2.TermEq.fv_cmp f1 f2 &&& FStar.Reflection.V2.TermEq.opt_dec_cmp p1 p2 (FStar.Reflection.V2.TermEq.list_dec_cmp p1 p2 FStar.Reflection.V2.TermEq.univ_cmp) ous1 ous2 &&& FStar.Reflection.V2.TermEq.list_dec_cmp p1 p2 FStar.Reflection.V2.TermEq.pat_arg_cmp args1 args2))
{ "end_col": 84, "end_line": 598, "start_col": 4, "start_line": 596 }
FStar.Pervasives.Lemma
val closure_transitive (#a: Type u#a) (#r_a: binrel u#a u#ra a) (x y z: a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)]
[ { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "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 closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z)
val closure_transitive (#a: Type u#a) (#r_a: binrel u#a u#ra a) (x y z: a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] let closure_transitive (#a: Type u#a) (#r_a: binrel u#a u#ra a) (x y z: a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] =
false
null
true
assert (closure r_a y z)
{ "checked_file": "FStar.LexicographicOrdering.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ "lemma" ]
[ "FStar.WellFounded.binrel", "Prims._assert", "FStar.ReflexiveTransitiveClosure.closure", "Prims.unit", "Prims.l_and", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
(* Copyright 2021 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. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y);
false
false
FStar.LexicographicOrdering.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 closure_transitive (#a: Type u#a) (#r_a: binrel u#a u#ra a) (x y z: a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)]
[]
FStar.LexicographicOrdering.closure_transitive
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> y: a -> z: a -> FStar.Pervasives.Lemma (requires FStar.ReflexiveTransitiveClosure.closure r_a x y /\ Prims.squash (r_a y z)) (ensures FStar.ReflexiveTransitiveClosure.closure r_a x z) [SMTPat (FStar.ReflexiveTransitiveClosure.closure r_a x y); SMTPat (r_a y z)]
{ "end_col": 28, "end_line": 33, "start_col": 4, "start_line": 33 }
Prims.Tot
val lex_t_wf (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (wf_a:well_founded r_a) (wf_b:(x:a -> well_founded (r_b x))) : well_founded (lex_t r_a r_b)
[ { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "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 lex_t_wf #_ #_ #_ #_ wf_a wf_b = fun (| x, y |) -> AccIntro (lex_t_wf_aux x (wf_a x) wf_b y (wf_b x y))
val lex_t_wf (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (wf_a:well_founded r_a) (wf_b:(x:a -> well_founded (r_b x))) : well_founded (lex_t r_a r_b) let lex_t_wf #_ #_ #_ #_ wf_a wf_b =
false
null
false
fun (| x , y |) -> AccIntro (lex_t_wf_aux x (wf_a x) wf_b y (wf_b x y))
{ "checked_file": "FStar.LexicographicOrdering.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ "total" ]
[ "FStar.WellFounded.binrel", "FStar.WellFounded.well_founded", "Prims.dtuple2", "FStar.WellFounded.AccIntro", "FStar.LexicographicOrdering.lex_t", "Prims.Mkdtuple2", "FStar.LexicographicOrdering.lex_t_wf_aux", "FStar.WellFounded.acc" ]
[]
(* Copyright 2021 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. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z) /// The main workhorse for the proof of lex_t well-foundedness /// /// Given x:a and (y:b x), along with proof of their accessibility, /// this function provides a proof of accessibility for all t s.t. lex_t t (| x, y |) /// /// The proof is by induction on the accessibility proofs of x and y /// In the Left_lex case, we do the induction on the accessibility of x, /// and in the Right_lex case, on the accessibility of y /// /// Note also that the proof _does not_ rely on the in-built lexicographic ordering in F* /// /// An interesting aspect of the proof is the wf_b argument, /// that provides a proof for the well-foundedness of r_b, /// but note that we only require it on elements of a that are related to x in the /// transitive closure of r_a let rec lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t (decreases acc_x) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> //inner induction that keeps x same, but recurses on acc_y let rec lex_t_wf_aux_y (y:b x) (acc_y:acc (r_b x) y) (t:(x:a & b x)) (p_t:lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t
false
false
FStar.LexicographicOrdering.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 lex_t_wf (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (wf_a:well_founded r_a) (wf_b:(x:a -> well_founded (r_b x))) : well_founded (lex_t r_a r_b)
[]
FStar.LexicographicOrdering.lex_t_wf
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
wf_a: FStar.WellFounded.well_founded r_a -> wf_b: (x: a -> FStar.WellFounded.well_founded (r_b x)) -> FStar.WellFounded.well_founded (FStar.LexicographicOrdering.lex_t r_a r_b)
{ "end_col": 72, "end_line": 96, "start_col": 2, "start_line": 96 }
Prims.Tot
val lex_t_non_dep_wf (#a:Type u#a) (#b:Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:binrel u#b u#rb b) (wf_a:well_founded r_a) (wf_b:well_founded r_b) : well_founded (lex_t_non_dep r_a r_b)
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "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 lex_t_non_dep_wf #a #b #r_a #r_b wf_a wf_b = let rec get_acc (t:a & b) (p:acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t)) : Tot (acc (lex_t_non_dep r_a r_b) t) (decreases p) = let get_acc_aux (t1:a & b) (p_dep:lex_t_non_dep r_a r_b t1 t) : (p1:acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t1){p1 << p}) = match p with | AccIntro f -> f (tuple_to_dep_tuple t1) p_dep in AccIntro (fun t1 p1 -> get_acc t1 (get_acc_aux t1 p1)) in fun t -> get_acc t (lex_t_wf wf_a (fun _ -> wf_b) (tuple_to_dep_tuple t))
val lex_t_non_dep_wf (#a:Type u#a) (#b:Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:binrel u#b u#rb b) (wf_a:well_founded r_a) (wf_b:well_founded r_b) : well_founded (lex_t_non_dep r_a r_b) let lex_t_non_dep_wf #a #b #r_a #r_b wf_a wf_b =
false
null
false
let rec get_acc (t: a & b) (p: acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t)) : Tot (acc (lex_t_non_dep r_a r_b) t) (decreases p) = let get_acc_aux (t1: a & b) (p_dep: lex_t_non_dep r_a r_b t1 t) : (p1: acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t1) {p1 << p}) = match p with | AccIntro f -> f (tuple_to_dep_tuple t1) p_dep in AccIntro (fun t1 p1 -> get_acc t1 (get_acc_aux t1 p1)) in fun t -> get_acc t (lex_t_wf wf_a (fun _ -> wf_b) (tuple_to_dep_tuple t))
{ "checked_file": "FStar.LexicographicOrdering.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ "total" ]
[ "FStar.WellFounded.binrel", "FStar.WellFounded.well_founded", "FStar.Pervasives.Native.tuple2", "FStar.LexicographicOrdering.lex_t_wf", "FStar.LexicographicOrdering.tuple_to_dep_tuple", "FStar.WellFounded.acc", "FStar.LexicographicOrdering.lex_t_non_dep", "Prims.dtuple2", "FStar.LexicographicOrdering.lex_t", "FStar.WellFounded.AccIntro", "Prims.precedes" ]
[]
(* Copyright 2021 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. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z) /// The main workhorse for the proof of lex_t well-foundedness /// /// Given x:a and (y:b x), along with proof of their accessibility, /// this function provides a proof of accessibility for all t s.t. lex_t t (| x, y |) /// /// The proof is by induction on the accessibility proofs of x and y /// In the Left_lex case, we do the induction on the accessibility of x, /// and in the Right_lex case, on the accessibility of y /// /// Note also that the proof _does not_ rely on the in-built lexicographic ordering in F* /// /// An interesting aspect of the proof is the wf_b argument, /// that provides a proof for the well-foundedness of r_b, /// but note that we only require it on elements of a that are related to x in the /// transitive closure of r_a let rec lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t (decreases acc_x) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> //inner induction that keeps x same, but recurses on acc_y let rec lex_t_wf_aux_y (y:b x) (acc_y:acc (r_b x) y) (t:(x:a & b x)) (p_t:lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t let lex_t_wf #_ #_ #_ #_ wf_a wf_b = fun (| x, y |) -> AccIntro (lex_t_wf_aux x (wf_a x) wf_b y (wf_b x y)) open FStar.Squash (* * Given lex_sq, we can output a squashed instance of lex *) let lex_to_lex_t #a #b r_a r_b t1 t2 p = let left (p:squash (r_a (dfst t1) (dfst t2))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> return_squash (Left_lex #a #b #r_a #r_b (dfst t1) (dfst t2) (dsnd t1) (dsnd t2) p)) in let right (p:(dfst t1 == dfst t2 /\ (squash (r_b (dfst t1) (dsnd t1) (dsnd t2))))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> match p with | Prims.Pair (_:dfst t1 == dfst t2) p2 -> bind_squash p2 (fun p2 -> return_squash (Right_lex #a #b #r_a #r_b (dfst t1) (dsnd t1) (dsnd t2) p2))) in bind_squash p (fun p -> match p with | Prims.Left p1 -> left p1 | Prims.Right p2 -> right p2)
false
false
FStar.LexicographicOrdering.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 lex_t_non_dep_wf (#a:Type u#a) (#b:Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:binrel u#b u#rb b) (wf_a:well_founded r_a) (wf_b:well_founded r_b) : well_founded (lex_t_non_dep r_a r_b)
[]
FStar.LexicographicOrdering.lex_t_non_dep_wf
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
wf_a: FStar.WellFounded.well_founded r_a -> wf_b: FStar.WellFounded.well_founded r_b -> FStar.WellFounded.well_founded (FStar.LexicographicOrdering.lex_t_non_dep r_a r_b)
{ "end_col": 75, "end_line": 132, "start_col": 48, "start_line": 123 }
Prims.Tot
val lex_to_lex_t (#a:Type u#a) (#b:a -> Type u#b) (r_a:binrel u#a u#ra a) (r_b:(x:a -> binrel u#b u#rb (b x))) (t1 t2:(x:a & b x)) (p:lex_aux r_a r_b t1 t2) : squash (lex_t r_a r_b t1 t2)
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "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 lex_to_lex_t #a #b r_a r_b t1 t2 p = let left (p:squash (r_a (dfst t1) (dfst t2))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> return_squash (Left_lex #a #b #r_a #r_b (dfst t1) (dfst t2) (dsnd t1) (dsnd t2) p)) in let right (p:(dfst t1 == dfst t2 /\ (squash (r_b (dfst t1) (dsnd t1) (dsnd t2))))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> match p with | Prims.Pair (_:dfst t1 == dfst t2) p2 -> bind_squash p2 (fun p2 -> return_squash (Right_lex #a #b #r_a #r_b (dfst t1) (dsnd t1) (dsnd t2) p2))) in bind_squash p (fun p -> match p with | Prims.Left p1 -> left p1 | Prims.Right p2 -> right p2)
val lex_to_lex_t (#a:Type u#a) (#b:a -> Type u#b) (r_a:binrel u#a u#ra a) (r_b:(x:a -> binrel u#b u#rb (b x))) (t1 t2:(x:a & b x)) (p:lex_aux r_a r_b t1 t2) : squash (lex_t r_a r_b t1 t2) let lex_to_lex_t #a #b r_a r_b t1 t2 p =
false
null
true
let left (p: squash (r_a (dfst t1) (dfst t2))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> return_squash (Left_lex #a #b #r_a #r_b (dfst t1) (dfst t2) (dsnd t1) (dsnd t2) p)) in let right (p: (dfst t1 == dfst t2 /\ (squash (r_b (dfst t1) (dsnd t1) (dsnd t2))))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (function | Prims.Pair (_: dfst t1 == dfst t2) p2 -> bind_squash p2 (fun p2 -> return_squash (Right_lex #a #b #r_a #r_b (dfst t1) (dsnd t1) (dsnd t2) p2))) in bind_squash p (function | Prims.Left p1 -> left p1 | Prims.Right p2 -> right p2)
{ "checked_file": "FStar.LexicographicOrdering.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ "total" ]
[ "FStar.WellFounded.binrel", "Prims.dtuple2", "FStar.LexicographicOrdering.lex_aux", "FStar.Squash.bind_squash", "Prims.sum", "Prims.squash", "FStar.Pervasives.dfst", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.dsnd", "FStar.LexicographicOrdering.lex_t", "Prims.pair", "Prims.Mkdtuple2", "FStar.Squash.return_squash", "FStar.LexicographicOrdering.Right_lex", "FStar.LexicographicOrdering.Left_lex" ]
[]
(* Copyright 2021 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. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z) /// The main workhorse for the proof of lex_t well-foundedness /// /// Given x:a and (y:b x), along with proof of their accessibility, /// this function provides a proof of accessibility for all t s.t. lex_t t (| x, y |) /// /// The proof is by induction on the accessibility proofs of x and y /// In the Left_lex case, we do the induction on the accessibility of x, /// and in the Right_lex case, on the accessibility of y /// /// Note also that the proof _does not_ rely on the in-built lexicographic ordering in F* /// /// An interesting aspect of the proof is the wf_b argument, /// that provides a proof for the well-foundedness of r_b, /// but note that we only require it on elements of a that are related to x in the /// transitive closure of r_a let rec lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t (decreases acc_x) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> //inner induction that keeps x same, but recurses on acc_y let rec lex_t_wf_aux_y (y:b x) (acc_y:acc (r_b x) y) (t:(x:a & b x)) (p_t:lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t let lex_t_wf #_ #_ #_ #_ wf_a wf_b = fun (| x, y |) -> AccIntro (lex_t_wf_aux x (wf_a x) wf_b y (wf_b x y)) open FStar.Squash (* * Given lex_sq, we can output a squashed instance of lex
false
false
FStar.LexicographicOrdering.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 lex_to_lex_t (#a:Type u#a) (#b:a -> Type u#b) (r_a:binrel u#a u#ra a) (r_b:(x:a -> binrel u#b u#rb (b x))) (t1 t2:(x:a & b x)) (p:lex_aux r_a r_b t1 t2) : squash (lex_t r_a r_b t1 t2)
[]
FStar.LexicographicOrdering.lex_to_lex_t
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r_a: FStar.WellFounded.binrel a -> r_b: (x: a -> FStar.WellFounded.binrel (b x)) -> t1: Prims.dtuple2 a (fun x -> b x) -> t2: Prims.dtuple2 a (fun x -> b x) -> p: FStar.LexicographicOrdering.lex_aux r_a r_b t1 t2 -> Prims.squash (FStar.LexicographicOrdering.lex_t r_a r_b t1 t2)
{ "end_col": 33, "end_line": 120, "start_col": 40, "start_line": 103 }
Prims.Tot
val lex_t_wf_aux (#a: Type u#a) (#b: (a -> Type u#b)) (#r_a: binrel u#a u#ra a) (#r_b: (x: a -> binrel u#b u#rb (b x))) (x: a) (acc_x: acc r_a x) (wf_b: (x0: a{closure r_a x0 x} -> well_founded (r_b x0))) (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_x)
[ { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "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 lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t (decreases acc_x) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> //inner induction that keeps x same, but recurses on acc_y let rec lex_t_wf_aux_y (y:b x) (acc_y:acc (r_b x) y) (t:(x:a & b x)) (p_t:lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t
val lex_t_wf_aux (#a: Type u#a) (#b: (a -> Type u#b)) (#r_a: binrel u#a u#ra a) (#r_b: (x: a -> binrel u#b u#rb (b x))) (x: a) (acc_x: acc r_a x) (wf_b: (x0: a{closure r_a x0 x} -> well_founded (r_b x0))) (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_x) let rec lex_t_wf_aux (#a: Type u#a) (#b: (a -> Type u#b)) (#r_a: binrel u#a u#ra a) (#r_b: (x: a -> binrel u#b u#rb (b x))) (x: a) (acc_x: acc r_a x) (wf_b: (x0: a{closure r_a x0 x} -> well_founded (r_b x0))) (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_x) =
false
null
false
match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> let rec lex_t_wf_aux_y (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t
{ "checked_file": "FStar.LexicographicOrdering.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ "total", "" ]
[ "FStar.WellFounded.binrel", "FStar.WellFounded.acc", "FStar.ReflexiveTransitiveClosure.closure", "FStar.WellFounded.well_founded", "Prims.dtuple2", "FStar.LexicographicOrdering.lex_t", "Prims.Mkdtuple2", "FStar.WellFounded.AccIntro", "FStar.LexicographicOrdering.lex_t_wf_aux" ]
[]
(* Copyright 2021 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. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z) /// The main workhorse for the proof of lex_t well-foundedness /// /// Given x:a and (y:b x), along with proof of their accessibility, /// this function provides a proof of accessibility for all t s.t. lex_t t (| x, y |) /// /// The proof is by induction on the accessibility proofs of x and y /// In the Left_lex case, we do the induction on the accessibility of x, /// and in the Right_lex case, on the accessibility of y /// /// Note also that the proof _does not_ rely on the in-built lexicographic ordering in F* /// /// An interesting aspect of the proof is the wf_b argument, /// that provides a proof for the well-foundedness of r_b, /// but note that we only require it on elements of a that are related to x in the /// transitive closure of r_a let rec lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t
false
false
FStar.LexicographicOrdering.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 lex_t_wf_aux (#a: Type u#a) (#b: (a -> Type u#b)) (#r_a: binrel u#a u#ra a) (#r_b: (x: a -> binrel u#b u#rb (b x))) (x: a) (acc_x: acc r_a x) (wf_b: (x0: a{closure r_a x0 x} -> well_founded (r_b x0))) (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_x)
[ "recursion" ]
FStar.LexicographicOrdering.lex_t_wf_aux
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> acc_x: FStar.WellFounded.acc r_a x -> wf_b: (x0: a{FStar.ReflexiveTransitiveClosure.closure r_a x0 x} -> FStar.WellFounded.well_founded (r_b x0)) -> y: b x -> acc_y: FStar.WellFounded.acc (r_b x) y -> t: Prims.dtuple2 a (fun x -> b x) -> p_t: FStar.LexicographicOrdering.lex_t r_a r_b t (| x, y |) -> Prims.Tot (FStar.WellFounded.acc (FStar.LexicographicOrdering.lex_t r_a r_b) t)
{ "end_col": 34, "end_line": 92, "start_col": 4, "start_line": 64 }
FStar.Pervasives.Lemma
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma (requires label r msg b) (ensures b) [SMTPat (label r msg b)]
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_label_bool r msg b = lemma_label_Type0 r msg b
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma (requires label r msg b) (ensures b) [SMTPat (label r msg b)] let lemma_label_bool r msg b =
false
null
true
lemma_label_Type0 r msg b
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "FStar.Range.range", "Prims.string", "Prims.bool", "Vale.X64.QuickCodes.lemma_label_Type0", "Prims.b2t", "Prims.unit" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = ()
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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_label_bool (r:range) (msg:string) (b:bool) : Lemma (requires label r msg b) (ensures b) [SMTPat (label r msg b)]
[]
Vale.X64.QuickCodes.lemma_label_bool
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: FStar.Range.range -> msg: Prims.string -> b: Prims.bool -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.label r msg b) (ensures b) [SMTPat (Vale.X64.QuickCodes.label r msg b)]
{ "end_col": 56, "end_line": 13, "start_col": 31, "start_line": 13 }
FStar.Pervasives.Lemma
val empty_list_is_small (#a:Type) (x:list a) : Lemma ([] #a == x \/ [] #a << x)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t
val empty_list_is_small (#a:Type) (x:list a) : Lemma ([] #a == x \/ [] #a << x) let rec empty_list_is_small #a x =
false
null
true
match x with | [] -> () | h :: t -> empty_list_is_small t
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Prims.list", "Vale.X64.QuickCodes.empty_list_is_small", "Prims.unit" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 empty_list_is_small (#a:Type) (x:list a) : Lemma ([] #a == x \/ [] #a << x)
[ "recursion" ]
Vale.X64.QuickCodes.empty_list_is_small
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.list a -> FStar.Pervasives.Lemma (ensures [] == x \/ [] << x)
{ "end_col": 33, "end_line": 18, "start_col": 2, "start_line": 16 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint
let state_mod_eq (m: mod_t) (s1 s2: vale_state) =
false
null
false
match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.mod_t", "Vale.X64.State.vale_state", "Prims.l_True", "Prims.eq2", "Prims.bool", "Vale.X64.State.__proj__Mkvale_state__item__vs_ok", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.t_reg", "Vale.X64.State.eval_reg", "Vale.X64.Flags.t", "Vale.X64.State.__proj__Mkvale_state__item__vs_flags", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout", "Vale.X64.Decls.heaplet_id", "Vale.Lib.Map16.sel", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.X64.Stack_i.vale_stack", "Vale.X64.State.__proj__Mkvale_state__item__vs_stack", "Vale.X64.Memory.memtaint", "Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint", "Prims.logical" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t
false
true
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 state_mod_eq : m: Vale.X64.QuickCode.mod_t -> s1: Vale.X64.State.vale_state -> s2: Vale.X64.State.vale_state -> Prims.logical
[]
Vale.X64.QuickCodes.state_mod_eq
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.X64.QuickCode.mod_t -> s1: Vale.X64.State.vale_state -> s2: Vale.X64.State.vale_state -> Prims.logical
{ "end_col": 58, "end_line": 30, "start_col": 2, "start_line": 21 }
FStar.Pervasives.Lemma
val update_state_mods_from1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
val update_state_mods_from1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') let update_state_mods_from1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
false
null
true
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.op_Negation", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.update_state_mods_not1", "Prims.bool", "Prims.unit", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.squash", "Prims.l_or", "Prims.b2t", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_from1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
[]
Vale.X64.QuickCodes.update_state_mods_from1
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.state_mod_eq m0 s' (Vale.X64.QuickCode.update_state_mods mods s' s)) (ensures Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s')
{ "end_col": 74, "end_line": 51, "start_col": 2, "start_line": 51 }
Prims.Ghost
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_block qcs mods s0 k) (ensures fun (sM, f0, g) -> eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_block qcs mods s0 k) (ensures fun (sM, f0, g) -> eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g ) let qblock_proof #a #cs qcs mods s0 k =
false
null
false
wp_sound cs (qcs s0) mods k s0
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.codes", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.mods_t", "Vale.X64.QuickCodes.wp_sound", "FStar.Pervasives.Native.tuple3", "Vale.X64.Decls.va_fuel" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_block qcs mods s0 k) (ensures fun (sM, f0, g) -> eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[]
Vale.X64.QuickCodes.qblock_proof
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
qcs: (_: Vale.X64.Decls.va_state -> Prims.GTot (Vale.X64.QuickCodes.quickCodes a cs)) -> mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
{ "end_col": 32, "end_line": 224, "start_col": 2, "start_line": 224 }
FStar.Pervasives.Lemma
val update_state_mods_trans (mods: mods_t) (s0 s1 s2: vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0
val update_state_mods_trans (mods: mods_t) (s0 s1 s2: vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) let update_state_mods_trans (mods: mods_t) (s0 s1 s2: vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) =
false
null
true
update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.update_state_mods_to", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_from", "Prims.l_and", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2)
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_trans (mods: mods_t) (s0 s1 s2: vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2)
[]
Vale.X64.QuickCodes.update_state_mods_trans
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.State.vale_state -> s1: Vale.X64.State.vale_state -> s2: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCode.update_state_mods mods s1 s0 == s1 /\ Vale.X64.QuickCode.update_state_mods mods s2 s1 == s2) (ensures Vale.X64.QuickCode.update_state_mods mods s2 s0 == s2)
{ "end_col": 33, "end_line": 115, "start_col": 2, "start_line": 113 }
Prims.Ghost
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) )
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g ) let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
false
null
false
if b then (let sM, f0, g = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g)) else (let sM, f0, g = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g))
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.code", "Prims.bool", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCode.__proj__QProc__item__proof" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[]
Vale.X64.QuickCodes.qInlineIf_proof
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Prims.bool -> qc1: Vale.X64.QuickCode.quickCode a c1 -> qc2: Vale.X64.QuickCode.quickCode a c2 -> mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
{ "end_col": 3, "end_line": 238, "start_col": 2, "start_line": 227 }
FStar.Pervasives.Lemma
val update_state_mods_from (mods: mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1
val update_state_mods_from (mods: mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) let update_state_mods_from (mods: mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) =
false
null
true
let f1 (m0: mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "FStar.Classical.forall_intro", "Vale.X64.QuickCode.mod_t", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.state_mod_eq", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.update_state_mods_from1", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Prims.l_Forall" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s'
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_from (mods: mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
[]
Vale.X64.QuickCodes.update_state_mods_from
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCode.update_state_mods mods s' s == s') (ensures forall (m0: Vale.X64.QuickCode.mod_t). {:pattern Vale.X64.QuickCodes.mods_contains1 mods m0\/Vale.X64.QuickCodes.state_mod_eq m0 s s'} Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s')
{ "end_col": 33, "end_line": 76, "start_col": 3, "start_line": 72 }
FStar.Pervasives.Lemma
val update_state_mods_weaken1 (mods mods': mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0
val update_state_mods_weaken1 (mods mods': mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) let rec update_state_mods_weaken1 (mods mods': mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) =
false
null
true
match mods with | [] -> () | _ :: mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "Prims.op_AmpAmp", "Vale.X64.QuickCodes.mods_contains", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.update_state_mods_weaken1", "Prims.bool", "Prims.unit", "Prims.l_and", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.state_mod_eq", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_weaken1 (mods mods': mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
[ "recursion" ]
Vale.X64.QuickCodes.update_state_mods_weaken1
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> mods': Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires (Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s') /\ Vale.X64.QuickCodes.mods_contains mods' mods) (ensures Vale.X64.QuickCodes.mods_contains1 mods' m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s')
{ "end_col": 52, "end_line": 125, "start_col": 2, "start_line": 121 }
FStar.Pervasives.Lemma
val update_state_mods_refl (mods: mods_t) (s: vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s
val update_state_mods_refl (mods: mods_t) (s: vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) let rec update_state_mods_refl (mods: mods_t) (s: vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) =
false
null
true
match mods with | [] -> () | _ :: mods -> update_state_mods_refl mods s
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "Vale.X64.QuickCodes.update_state_mods_refl", "Prims.unit", "Prims.l_True", "Prims.squash", "Vale.X64.State.state_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s)
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_refl (mods: mods_t) (s: vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s)
[ "recursion" ]
Vale.X64.QuickCodes.update_state_mods_refl
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (ensures Vale.X64.State.state_eq (Vale.X64.QuickCode.update_state_mods mods s s) s)
{ "end_col": 44, "end_line": 37, "start_col": 2, "start_line": 35 }
FStar.Pervasives.Lemma
val update_state_mods_weaken (mods mods': mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s')
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s
val update_state_mods_weaken (mods mods': mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') let update_state_mods_weaken (mods mods': mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') =
false
null
true
update_state_mods_from mods s' s; let f1 (m0: mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.update_state_mods_to", "Prims.unit", "FStar.Classical.forall_intro", "Vale.X64.QuickCode.mod_t", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.state_mod_eq", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.update_state_mods_weaken1", "Vale.X64.QuickCodes.update_state_mods_from", "Prims.l_and", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Vale.X64.QuickCodes.mods_contains" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s')
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_weaken (mods mods': mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s')
[]
Vale.X64.QuickCodes.update_state_mods_weaken
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> mods': Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCode.update_state_mods mods s' s == s' /\ Vale.X64.QuickCodes.mods_contains mods' mods) (ensures Vale.X64.QuickCode.update_state_mods mods' s' s == s')
{ "end_col": 33, "end_line": 136, "start_col": 2, "start_line": 131 }
Prims.Ghost
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & fuel & a) (requires t_require s0 /\ QProc?.wp qc s0 k) (ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & fuel & a) (requires t_require s0 /\ QProc?.wp qc s0 k) (ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN) let wp_sound_code #a c qc k s0 =
false
null
false
let QProc c _ wp proof = qc in proof s0 k
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCode.quickCode", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_code", "Vale.X64.QuickCode.mods_t", "Vale.X64.QuickCode.quickProc_wp", "Vale.X64.QuickCode.t_proof", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCodes.fuel" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in ()
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & fuel & a) (requires t_require s0 /\ QProc?.wp qc s0 k) (ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
[]
Vale.X64.QuickCodes.wp_sound_code
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.QuickCodes.code -> qc: Vale.X64.QuickCode.quickCode a c -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> s0: Vale.X64.Decls.va_state -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.QuickCodes.fuel) * a)
{ "end_col": 12, "end_line": 319, "start_col": 32, "start_line": 317 }
Prims.Tot
val qAssertLemma (p:Type0) : tAssertLemma p
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 qAssertLemma p = fun () -> ()
val qAssertLemma (p:Type0) : tAssertLemma p let qAssertLemma p =
false
null
false
fun () -> ()
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "total" ]
[ "Prims.unit" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 qAssertLemma (p:Type0) : tAssertLemma p
[]
Vale.X64.QuickCodes.qAssertLemma
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Type0 -> Vale.X64.QuickCodes.tAssertLemma p
{ "end_col": 33, "end_line": 310, "start_col": 21, "start_line": 310 }
FStar.Pervasives.Lemma
val update_state_mods_not1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0
val update_state_mods_not1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) let rec update_state_mods_not1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) =
false
null
true
match mods with | [] -> () | _ :: mods -> update_state_mods_not1 mods s' s m0
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "Vale.X64.QuickCodes.update_state_mods_not1", "Prims.unit", "Prims.b2t", "Prims.op_Negation", "Vale.X64.QuickCodes.mods_contains1", "Prims.squash", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s))
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_not1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s))
[ "recursion" ]
Vale.X64.QuickCodes.update_state_mods_not1
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires Prims.op_Negation (Vale.X64.QuickCodes.mods_contains1 mods m0)) (ensures Vale.X64.QuickCodes.state_mod_eq m0 s (Vale.X64.QuickCode.update_state_mods mods s' s))
{ "end_col": 50, "end_line": 45, "start_col": 2, "start_line": 43 }
Prims.Tot
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 qAssertSquashLemma p = fun () -> ()
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p let qAssertSquashLemma p =
false
null
false
fun () -> ()
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "total" ]
[ "Prims.unit", "Prims.squash" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> ()
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
[]
Vale.X64.QuickCodes.qAssertSquashLemma
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Type0 -> Vale.X64.QuickCodes.tAssertSquashLemma p
{ "end_col": 39, "end_line": 312, "start_col": 27, "start_line": 312 }
FStar.Pervasives.Lemma
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma (requires state_match s0 s1) (ensures state_eq s0 s1)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_state_match s0 s1 = lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs)
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma (requires state_match s0 s1) (ensures state_eq s0 s1) let lemma_state_match s0 s1 =
false
null
true
lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs)
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.Decls.va_state", "Prims._assert", "Vale.X64.Regs.equal", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Prims.unit", "Vale.X64.QuickCodes.lemma_regs_match", "Vale.X64.Machine_s.n_reg_files" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1) let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1))
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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_state_match (s0:va_state) (s1:va_state) : Lemma (requires state_match s0 s1) (ensures state_eq s0 s1)
[]
Vale.X64.QuickCodes.lemma_state_match
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Vale.X64.Decls.va_state -> s1: Vale.X64.Decls.va_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.state_match s0 s1) (ensures Vale.X64.State.state_eq s0 s1)
{ "end_col": 43, "end_line": 337, "start_col": 2, "start_line": 336 }
Prims.Ghost
val wp_sound_code_wrap (#a: Type0) (c: code) (qc: quickCode a c) (s0: vale_state) (k: (s0': vale_state{s0 == s0'} -> vale_state -> a -> Type0)) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:vale_state) (k:(s0':vale_state{s0 == s0'}) -> vale_state -> a -> Type0) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k) = wp_sound_code c qc (k s0) s0
val wp_sound_code_wrap (#a: Type0) (c: code) (qc: quickCode a c) (s0: vale_state) (k: (s0': vale_state{s0 == s0'} -> vale_state -> a -> Type0)) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k) let wp_sound_code_wrap (#a: Type0) (c: code) (qc: quickCode a c) (s0: vale_state) (k: (s0': vale_state{s0 == s0'} -> vale_state -> a -> Type0)) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k) =
false
null
false
wp_sound_code c qc (k s0) s0
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCode.quickCode", "Vale.X64.State.vale_state", "Prims.eq2", "Vale.X64.QuickCodes.wp_sound_code", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCodes.fuel", "Prims.l_and", "Vale.X64.QuickCode.t_require", "Vale.X64.QuickCodes.wp_sound_code_pre", "Vale.X64.QuickCodes.wp_sound_code_post" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1) let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1)) let lemma_state_match s0 s1 = lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs) let wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:vale_state) (k:(s0':vale_state{s0 == s0'}) -> vale_state -> a -> Type0) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k)
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 wp_sound_code_wrap (#a: Type0) (c: code) (qc: quickCode a c) (s0: vale_state) (k: (s0': vale_state{s0 == s0'} -> vale_state -> a -> Type0)) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k)
[]
Vale.X64.QuickCodes.wp_sound_code_wrap
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.QuickCodes.code -> qc: Vale.X64.QuickCode.quickCode a c -> s0: Vale.X64.State.vale_state -> k: (s0': Vale.X64.State.vale_state{s0 == s0'} -> _: Vale.X64.State.vale_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.State.vale_state * Vale.X64.QuickCodes.fuel) * a)
{ "end_col": 30, "end_line": 344, "start_col": 2, "start_line": 344 }
FStar.Pervasives.Lemma
val update_state_mods_to (mods: mods_t) (s' s: vale_state) : Lemma (requires (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) (ensures state_eq s' (update_state_mods mods s' s))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in ()
val update_state_mods_to (mods: mods_t) (s' s: vale_state) : Lemma (requires (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) (ensures state_eq s' (update_state_mods mods s' s)) let update_state_mods_to (mods: mods_t) (s' s: vale_state) : Lemma (requires (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) (ensures state_eq s' (update_state_mods mods s' s)) =
false
null
true
let s'' = update_state_mods mods s' s in let f1 (m0: mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r: reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n: heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in ()
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.Arch.HeapImpl.heaplet_id", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Arch.HeapImpl.vale_heap", "Vale.Lib.Map16.sel", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil", "Vale.X64.QuickCode.Mod_mem_heaplet", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.t_reg", "Vale.X64.Regs.sel", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Vale.X64.QuickCode.Mod_reg", "Vale.X64.QuickCode.Mod_stackTaint", "Vale.X64.QuickCode.Mod_stack", "Vale.X64.QuickCode.Mod_mem_layout", "Vale.X64.QuickCode.Mod_mem", "Vale.X64.QuickCode.Mod_flags", "Vale.X64.QuickCode.Mod_ok", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCodes.update_state_mods_to1", "Vale.X64.QuickCode.update_state_mods", "Prims.l_Forall", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.State.state_eq" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' ))
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_to (mods: mods_t) (s' s: vale_state) : Lemma (requires (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) (ensures state_eq s' (update_state_mods mods s' s))
[]
Vale.X64.QuickCodes.update_state_mods_to
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires forall (m0: Vale.X64.QuickCode.mod_t). {:pattern Vale.X64.QuickCodes.mods_contains1 mods m0\/Vale.X64.QuickCodes.state_mod_eq m0 s s'} Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s') (ensures Vale.X64.State.state_eq s' (Vale.X64.QuickCode.update_state_mods mods s' s))
{ "end_col": 4, "end_line": 107, "start_col": 3, "start_line": 84 }
Prims.Ghost
val qWhile_proof (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0) (dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k) (ensures fun (sM, f0, g) -> eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
val qWhile_proof (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0) (dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k) (ensures fun (sM, f0, g) -> eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
false
null
false
let ob = cmp_to_ocmp b in let s1, f1 = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCodes.cmp", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCodes.qWhile_proof_rec", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_refl", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_while_total", "Vale.X64.Decls.ocmp", "Vale.X64.QuickCodes.cmp_to_ocmp" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) )
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 qWhile_proof (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0) (dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k) (ensures fun (sM, f0, g) -> eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[]
Vale.X64.QuickCodes.qWhile_proof
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.X64.QuickCodes.cmp -> qc: (_: a -> Vale.X64.QuickCode.quickCode a c) -> mods: Vale.X64.QuickCode.mods_t -> inv: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> dec: (_: Vale.X64.Decls.va_state -> _: a -> d) -> g0: a -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
{ "end_col": 50, "end_line": 308, "start_col": 53, "start_line": 304 }
FStar.Pervasives.Lemma
val call_QPURE (#a: Type0) (#cs: codes) (r: range) (msg: string) (pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l: (unit -> PURE unit (as_pure_wp pre))) (qcs: quickCodes a cs) (mods: mods_t) (k: (vale_state -> a -> Type0)) (s0: vale_state) : Lemma (requires (forall (p: (unit -> GTot Type0)). {:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l ()
val call_QPURE (#a: Type0) (#cs: codes) (r: range) (msg: string) (pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l: (unit -> PURE unit (as_pure_wp pre))) (qcs: quickCodes a cs) (mods: mods_t) (k: (vale_state -> a -> Type0)) (s0: vale_state) : Lemma (requires (forall (p: (unit -> GTot Type0)). {:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) let call_QPURE (#a: Type0) (#cs: codes) (r: range) (msg: string) (pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l: (unit -> PURE unit (as_pure_wp pre))) (qcs: quickCodes a cs) (mods: mods_t) (k: (vale_state -> a -> Type0)) (s0: vale_state) : Lemma (requires (forall (p: (unit -> GTot Type0)). {:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) =
false
null
true
l ()
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCodes.codes", "FStar.Range.range", "Prims.string", "Prims.unit", "FStar.Monotonic.Pure.is_monotonic", "FStar.Monotonic.Pure.as_pure_wp", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Prims.l_Forall", "Prims.l_imp", "Vale.X64.QuickCodes.wp", "Vale.X64.QuickCodes.label", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0)
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 call_QPURE (#a: Type0) (#cs: codes) (r: range) (msg: string) (pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l: (unit -> PURE unit (as_pure_wp pre))) (qcs: quickCodes a cs) (mods: mods_t) (k: (vale_state -> a -> Type0)) (s0: vale_state) : Lemma (requires (forall (p: (unit -> GTot Type0)). {:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0)
[]
Vale.X64.QuickCodes.call_QPURE
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: FStar.Range.range -> msg: Prims.string -> pre: (_: (_: Prims.unit -> Prims.GTot Type0) -> Prims.GTot Type0) {FStar.Monotonic.Pure.is_monotonic pre} -> l: (_: Prims.unit -> Prims.PURE Prims.unit) -> qcs: Vale.X64.QuickCodes.quickCodes a cs -> mods: Vale.X64.QuickCode.mods_t -> k: (_: Vale.X64.State.vale_state -> _: a -> Type0) -> s0: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires forall (p: (_: Prims.unit -> Prims.GTot Type0)). {:pattern pre p} (Vale.X64.QuickCodes.wp cs qcs mods k s0 ==> p ()) ==> Vale.X64.QuickCodes.label r msg (pre p)) (ensures Vale.X64.QuickCodes.wp cs qcs mods k s0)
{ "end_col": 6, "end_line": 147, "start_col": 2, "start_line": 147 }
FStar.Pervasives.Lemma
val update_state_mods_to1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2
val update_state_mods_to1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) let rec update_state_mods_to1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) =
false
null
true
match mods with | [] -> () | r :: mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_: squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_: squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_: squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "FStar.Classical.or_elim", "Prims.l_not", "Prims.squash", "Prims.unit", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.update_state_mods_to1", "Prims.l_or", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.logical", "Prims.eq2", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s))
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 update_state_mods_to1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s))
[ "recursion" ]
Vale.X64.QuickCodes.update_state_mods_to1
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s') (ensures Vale.X64.QuickCodes.state_mod_eq m0 s' (Vale.X64.QuickCode.update_state_mods mods s' s))
{ "end_col": 50, "end_line": 64, "start_col": 2, "start_line": 57 }
Prims.Ghost
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp cs qcs mods k s0) (ensures fun (sN, fN, gN) -> eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN )
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp cs qcs mods k s0) (ensures fun (sN, fN, gN) -> eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN ) let rec wp_sound #a cs qcs mods k s0 =
false
null
false
let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let sN, fN = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c :: cs = cs in let k' = wp_Seq cs qcs mods k in let sM, fM, gM = proof s0 k' in let sN, fN, gN = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c :: cs = cs in let k' = wp_Bind cs qcs mods k in let sM, fM, gM = proof s0 k' in let sN, fN, gN = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c :: cs = cs in let sM, fM = va_lemma_empty_total s0 [] in let sN, fN, gN = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c :: cs = cs in let sM, fM = va_lemma_empty_total s0 [] in let g = l () in let sN, fN, gN = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.codes", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.Nil", "Vale.X64.Decls.va_code", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_refl", "Vale.X64.QuickCodes.code", "FStar.Range.range", "Prims.string", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.quickProc_wp", "Vale.X64.QuickCode.t_proof", "Prims.list", "Vale.X64.QuickCodes.update_state_mods_trans", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.X64.Decls.va_lemma_merge_total", "Prims.Cons", "Vale.X64.QuickCodes.wp_sound", "Vale.X64.QuickCodes.wp_Seq_t", "Vale.X64.QuickCodes.wp_Seq", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.QuickCodes.wp_Bind_t", "Vale.X64.QuickCodes.wp_Bind", "FStar.Monotonic.Pure.is_monotonic", "FStar.Monotonic.Pure.as_pure_wp", "Vale.X64.QuickCodes.call_QPURE", "Prims.squash", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.k_AssertBy", "Vale.X64.QuickCodes.empty_list_is_small" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *)
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp cs qcs mods k s0) (ensures fun (sN, fN, gN) -> eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN )
[ "recursion" ]
Vale.X64.QuickCodes.wp_sound
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
cs: Vale.X64.QuickCodes.codes -> qcs: Vale.X64.QuickCodes.quickCodes a cs -> mods: Vale.X64.QuickCode.mods_t -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> s0: Vale.X64.Decls.va_state -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
{ "end_col": 31, "end_line": 221, "start_col": 38, "start_line": 164 }
Prims.Ghost
val va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Ghost (va_state & fuel & a) (t_require s0 /\ normal (wp_sound_code_pre qc s0 k)) (wp_sound_code_post qc s0 k)
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 va_wp_sound_code_norm #a c qc s0 k = assert_normal (wp_sound_code_pre qc s0 k); wp_sound_code_wrap c qc s0 k
val va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Ghost (va_state & fuel & a) (t_require s0 /\ normal (wp_sound_code_pre qc s0 k)) (wp_sound_code_post qc s0 k) let va_wp_sound_code_norm #a c qc s0 k =
false
null
false
assert_normal (wp_sound_code_pre qc s0 k); wp_sound_code_wrap c qc s0 k
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCode.quickCode", "Vale.X64.Decls.va_state", "Prims.eq2", "Vale.X64.QuickCodes.wp_sound_code_wrap", "Prims.unit", "Vale.X64.QuickCodes.assert_normal", "Vale.X64.QuickCodes.wp_sound_code_pre", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCodes.fuel" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1) let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1)) let lemma_state_match s0 s1 = lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs) let wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:vale_state) (k:(s0':vale_state{s0 == s0'}) -> vale_state -> a -> Type0) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k) = wp_sound_code c qc (k s0) s0 let assert_normal (p:Type) : Lemma (requires normal p) (ensures p) = ()
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Ghost (va_state & fuel & a) (t_require s0 /\ normal (wp_sound_code_pre qc s0 k)) (wp_sound_code_post qc s0 k)
[]
Vale.X64.QuickCodes.va_wp_sound_code_norm
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.QuickCodes.code -> qc: Vale.X64.QuickCode.quickCode a c -> s0: Vale.X64.Decls.va_state -> k: (s0': Vale.X64.Decls.va_state{s0 == s0'} -> _: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.QuickCodes.fuel) * a)
{ "end_col": 30, "end_line": 354, "start_col": 2, "start_line": 353 }
Prims.Ghost
val qWhile_proof_rec (#a #d: Type) (#c: code) (b: cmp) (qc: (a -> quickCode a c)) (mods: mods_t) (inv: (vale_state -> a -> Type0)) (dec: (vale_state -> a -> d)) (s0 s1: vale_state) (g1: a) (f1: fuel) (k: (vale_state -> a -> Type0)) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2) (decreases (dec s1 g1))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) )
val qWhile_proof_rec (#a #d: Type) (#c: code) (b: cmp) (qc: (a -> quickCode a c)) (mods: mods_t) (inv: (vale_state -> a -> Type0)) (dec: (vale_state -> a -> d)) (s0 s1: vale_state) (g1: a) (f1: fuel) (k: (vale_state -> a -> Type0)) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2) (decreases (dec s1 g1)) let rec qWhile_proof_rec (#a #d: Type) (#c: code) (b: cmp) (qc: (a -> quickCode a c)) (mods: mods_t) (inv: (vale_state -> a -> Type0)) (dec: (vale_state -> a -> d)) (s0 s1: vale_state) (g1: a) (f1: fuel) (k: (vale_state -> a -> Type0)) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2) (decreases (dec s1 g1)) =
false
null
false
let ob = cmp_to_ocmp b in let s1' = { s1 with vs_flags = havoc_flags } in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then (let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let s2, f2 = va_lemma_whileTrue_total ob c s0 s1 f1 in let sc, fc, gc = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k) else (let s2, f2 = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1))
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "" ]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCodes.cmp", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.fuel", "Vale.X64.QuickCodes.eval_cmp", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCodes.qWhile_proof_rec", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_trans", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.X64.Decls.va_lemma_whileMerge_total", "Vale.X64.Machine_s.While", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCode.__proj__QProc__item__proof", "FStar.Pervasives.Native.tuple2", "Vale.X64.Decls.va_lemma_whileTrue_total", "Vale.X64.QuickCode.quickProc_wp", "Vale.X64.QuickCode.__proj__QProc__item__wp", "Vale.X64.QuickCodes.wp_While_inv", "Prims.bool", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.Decls.va_lemma_whileFalse_total", "Vale.X64.QuickCodes.update_state_mods_to", "Vale.X64.State.Mkvale_state", "Vale.X64.State.__proj__Mkvale_state__item__vs_ok", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Vale.X64.Decls.havoc_flags", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Vale.X64.State.__proj__Mkvale_state__item__vs_stack", "Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint", "Vale.X64.QuickCodes.cmp_to_ocmp", "Prims.l_and", "Vale.X64.Decls.state_inv", "Vale.X64.QuickCodes.wp_While", "Vale.X64.Decls.eval_while_inv", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Vale.X64.Decls.eval_code" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 )
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 qWhile_proof_rec (#a #d: Type) (#c: code) (b: cmp) (qc: (a -> quickCode a c)) (mods: mods_t) (inv: (vale_state -> a -> Type0)) (dec: (vale_state -> a -> d)) (s0 s1: vale_state) (g1: a) (f1: fuel) (k: (vale_state -> a -> Type0)) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2) (decreases (dec s1 g1))
[ "recursion" ]
Vale.X64.QuickCodes.qWhile_proof_rec
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.X64.QuickCodes.cmp -> qc: (_: a -> Vale.X64.QuickCode.quickCode a c) -> mods: Vale.X64.QuickCode.mods_t -> inv: (_: Vale.X64.State.vale_state -> _: a -> Type0) -> dec: (_: Vale.X64.State.vale_state -> _: a -> d) -> s0: Vale.X64.State.vale_state -> s1: Vale.X64.State.vale_state -> g1: a -> f1: Vale.X64.QuickCodes.fuel -> k: (_: Vale.X64.State.vale_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.State.vale_state * Vale.X64.Decls.va_fuel) * a)
{ "end_col": 3, "end_line": 302, "start_col": 3, "start_line": 282 }
Prims.Ghost
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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 qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) )
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
false
null
false
(match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2); let s1 = { s0 with vs_flags = havoc_flags } in update_state_mods_to mods s1 s0; if eval_cmp s0 b then (let sM, f0, g = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g)) else (let sM, f0, g = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g))
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCodes.cmp", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.eval_cmp", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_trans", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.X64.Decls.va_lemma_ifElseTrue_total", "Vale.X64.QuickCodes.cmp_to_ocmp", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCode.__proj__QProc__item__proof", "Prims.bool", "Vale.X64.Decls.va_lemma_ifElseFalse_total", "Vale.X64.QuickCodes.update_state_mods_to", "Vale.X64.State.Mkvale_state", "Vale.X64.State.__proj__Mkvale_state__item__vs_ok", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Vale.X64.Decls.havoc_flags", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Vale.X64.State.__proj__Mkvale_state__item__vs_stack", "Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint", "Vale.X64.Machine_s.operand64", "Prims.b2t", "Prims.op_Negation", "Prims.op_BarBar", "Vale.X64.Machine_s.uu___is_OMem", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.uu___is_OStack", "Vale.X64.Decls.lemma_cmp_eq", "Vale.X64.Decls.lemma_valid_cmp_eq", "Vale.X64.Decls.lemma_cmp_ne", "Vale.X64.Decls.lemma_valid_cmp_ne", "Vale.X64.Decls.lemma_cmp_le", "Vale.X64.Decls.lemma_valid_cmp_le", "Vale.X64.Decls.lemma_cmp_ge", "Vale.X64.Decls.lemma_valid_cmp_ge", "Vale.X64.Decls.lemma_cmp_lt", "Vale.X64.Decls.lemma_valid_cmp_lt", "Vale.X64.Decls.lemma_cmp_gt", "Vale.X64.Decls.lemma_valid_cmp_gt" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) )
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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 qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
[]
Vale.X64.QuickCodes.qIf_proof
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.X64.QuickCodes.cmp -> qc1: Vale.X64.QuickCode.quickCode a c1 -> qc2: Vale.X64.QuickCode.quickCode a c2 -> mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
{ "end_col": 3, "end_line": 266, "start_col": 2, "start_line": 241 }
FStar.Pervasives.Lemma
val lemma_regs_match_file (r0 r1: Regs.t) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i: nat). {:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1)))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1)
val lemma_regs_match_file (r0 r1: Regs.t) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i: nat). {:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) let rec lemma_regs_match_file (r0 r1: Regs.t) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i: nat). {:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) =
false
null
true
if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1)
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.Regs.t", "Vale.X64.Machine_s.reg_file_id", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.X64.Machine_s.n_regs", "Prims.op_GreaterThan", "Vale.X64.QuickCodes.lemma_regs_match_file", "Prims.op_Subtraction", "Prims.bool", "Prims.unit", "Vale.X64.QuickCodes.regs_match_file", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThan", "Prims.eq2", "Vale.X64.Machine_s.t_reg", "Vale.X64.Regs.sel", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.Reg", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1)))
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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_regs_match_file (r0 r1: Regs.t) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i: nat). {:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1)))
[ "recursion" ]
Vale.X64.QuickCodes.lemma_regs_match_file
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r0: Vale.X64.Regs.t -> r1: Vale.X64.Regs.t -> rf: Vale.X64.Machine_s.reg_file_id -> k: Prims.nat{k <= Vale.X64.Machine_s.n_regs rf} -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.regs_match_file r0 r1 rf k) (ensures forall (i: Prims.nat). {:pattern Vale.X64.Machine_s.Reg rf i} i < k ==> (let r = Vale.X64.Machine_s.Reg rf i in Vale.X64.Regs.sel r r0 == Vale.X64.Regs.sel r r1))
{ "end_col": 54, "end_line": 326, "start_col": 2, "start_line": 326 }
FStar.Pervasives.Lemma
val lemma_regs_match (r0 r1: Regs.t) (k: nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i: nat) (j: nat). {:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1)))
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "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_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1))
val lemma_regs_match (r0 r1: Regs.t) (k: nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i: nat) (j: nat). {:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) let rec lemma_regs_match (r0 r1: Regs.t) (k: nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i: nat) (j: nat). {:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) =
false
null
true
if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1))
{ "checked_file": "Vale.X64.QuickCodes.fst.checked", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ "lemma" ]
[ "Vale.X64.Regs.t", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.X64.Machine_s.n_reg_files", "Prims.op_GreaterThan", "Vale.X64.QuickCodes.lemma_regs_match", "Prims.op_Subtraction", "Prims.unit", "Vale.X64.QuickCodes.lemma_regs_match_file", "Vale.X64.Machine_s.n_regs", "Prims.bool", "Vale.X64.QuickCodes.regs_match", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.op_LessThan", "Prims.eq2", "Vale.X64.Machine_s.t_reg", "Vale.X64.Regs.sel", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.Reg", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1) let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1)))
false
false
Vale.X64.QuickCodes.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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_regs_match (r0 r1: Regs.t) (k: nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i: nat) (j: nat). {:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1)))
[ "recursion" ]
Vale.X64.QuickCodes.lemma_regs_match
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r0: Vale.X64.Regs.t -> r1: Vale.X64.Regs.t -> k: Prims.nat{k <= Vale.X64.Machine_s.n_reg_files} -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.regs_match r0 r1 k) (ensures forall (i: Prims.nat) (j: Prims.nat). {:pattern Vale.X64.Machine_s.Reg i j} i < k /\ j < Vale.X64.Machine_s.n_regs i ==> (let r = Vale.X64.Machine_s.Reg i j in Vale.X64.Regs.sel r r0 == Vale.X64.Regs.sel r r1))
{ "end_col": 102, "end_line": 333, "start_col": 2, "start_line": 333 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "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 supported_alg = a:hash_alg{ is_supported_alg a }
let supported_alg =
false
null
false
a: hash_alg{is_supported_alg a}
{ "checked_file": "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Meta.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Spec.HMAC_DRBG.Test.Vectors.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.HMAC_DRBG.Test.Vectors.is_supported_alg" ]
[]
module Spec.HMAC_DRBG.Test.Vectors open Lib.Meta open Spec.Hash.Definitions #set-options "--fuel 0 --ifuel 0" /// /// HMAC-DRBG test vectors from NIST CAVP /// https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators#DRBG /// let is_supported_alg = function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false
false
true
Spec.HMAC_DRBG.Test.Vectors.fst
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val supported_alg : Type0
[]
Spec.HMAC_DRBG.Test.Vectors.supported_alg
{ "file_name": "specs/drbg/Spec.HMAC_DRBG.Test.Vectors.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 52, "end_line": 17, "start_col": 20, "start_line": 17 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "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 is_supported_alg = function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false
let is_supported_alg =
false
null
false
function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false
{ "checked_file": "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Meta.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Spec.HMAC_DRBG.Test.Vectors.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.hash_alg", "Prims.bool" ]
[]
module Spec.HMAC_DRBG.Test.Vectors open Lib.Meta open Spec.Hash.Definitions #set-options "--fuel 0 --ifuel 0" /// /// HMAC-DRBG test vectors from NIST CAVP /// https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators#DRBG ///
false
true
Spec.HMAC_DRBG.Test.Vectors.fst
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_supported_alg : _: Spec.Hash.Definitions.hash_alg -> Prims.bool
[]
Spec.HMAC_DRBG.Test.Vectors.is_supported_alg
{ "file_name": "specs/drbg/Spec.HMAC_DRBG.Test.Vectors.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Spec.Hash.Definitions.hash_alg -> Prims.bool
{ "end_col": 14, "end_line": 15, "start_col": 23, "start_line": 13 }
Prims.Tot
val test_vectors:list vec
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "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 test_vectors : list vec = [ { a = SHA1; entropy_input = "7cad65e5cc2888ae4e960f5d143c1425"; nonce = "fc0785db471cc55e"; personalization_string = ""; entropy_input_reseed = "66451d29cf65d899a281905ff9b29e87"; additional_input_reseed = "800d583b2560d2a2300132ee2d13f19f"; additional_input_1 = "42eae705c2225d212fa0554ac6ac564b"; additional_input_2 = "72081e7e70200f1982c3ad9cb1d3ddbe"; returned_bits = "953e92258be7ff61b97077252ab9835231e366dfa5b635fb889c337562a2641d3aa9e46feeb2a4ea03cb73f1f801594c3cc71d2945c11a52bb0e93419df5d0854ad5f2e36d223c119e145cad507495a7"; } ; { a = SHA1; entropy_input = "0736a083595a8397cb9e676cb37bfb5a"; nonce = "0b184a6d0a630abb"; personalization_string = "c302503d86a2bde46a0c63561a86cfd9"; entropy_input_reseed = "4b50977033483277647945ffefa109e2"; additional_input_reseed = "4dad813744f54324b3046a85be3cc3c8"; additional_input_1 = "7441fefa60f7ee48ff387b587efcb3e6"; additional_input_2 = "f0d005289a9d3993c44bb750d96cc1bc"; returned_bits = "c03971897b854585994eeb8e3d6b556e1a8df18a7ff88f83e8fe17e6dd9071070a6dbef67cb612acf122caa7f817704b3efc6e1b1fd6c330e0a732abea93c00818e12c504fd8e0b36c88f84a95b49362"; } ; { a = SHA1; entropy_input = "172054c827aa895fa1239b7a484752f2"; nonce = "edb272c0a98c7592"; personalization_string = "47bc78bfbd1bb7e2dcdbf4ebe42c5293"; entropy_input_reseed = "29f92a0e5d24e19af698877f69a0efb5"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6464bdaed23245db1f6510f8659e1b19881d606220997b837684a7f88a166cb75ce6829cb3f11e55d2b7ad349cc1f4ba02e30a76f970613aa74635b0034f8e985cde4f1fddb964657a169386e20767d1"; } ; { a = SHA1; entropy_input = "b1a19bb07c30ca4f49dc69130d23c0a7"; nonce = "2c06067297058ec5"; personalization_string = ""; entropy_input_reseed = "840802cea2e55a3b1e487bb7aee62b42"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f41bb7ae532344a90d413b66a94ee1d0254a5d5e974e36b1993b1042586f54728d1ebb7c5d351558ed675177e432360708c008984c41bc4c828d83ddeca9ef8ecd9da880a135400a43f91f4ca6d59d00"; } ; { a = SHA1; entropy_input = "343f9dde89a9e3ecc4f9653c8b392dab"; nonce = "c4fb3606d8f62db1"; personalization_string = ""; entropy_input_reseed = "021fc3ead46ff8bda3b79701b7893a39"; additional_input_reseed = "8918831e15d430616f4bd91046fe0930"; additional_input_1 = "a8772304a1accb16662218a748bb4fd8"; additional_input_2 = "4bf9f2b9d15ec3071ff3674ad7418759"; returned_bits = "9782b2111c985bcaab0b8905ad9bcb97eb3f3554c68d79ee5ca1dcfbd0d7850f65090c79d21d1c6253cf493f08392cfb60461fbc20beb4cf3e022123816f0bc597abebc775633db324c7c1c7cd5e8c56"; } ; { a = SHA1; entropy_input = "0a086726f66f2ac9e7daa61908f63319"; nonce = "debf011d406a5b23"; personalization_string = "58582da74f8f91db0444beae39016857"; entropy_input_reseed = "c92ba2900ab0a4ca3553806392b6b3e5"; additional_input_reseed = "5604a76e74ef4b304466f21df57c70f3"; additional_input_1 = "e1e4d0754cc306a1752b50c5c446a3d0"; additional_input_2 = "71dacf61875cbf3655e4f7d2e081d493"; returned_bits = "afbb3a05e753f6ebf026594a03b22b3f032edb873b9e1e22532e360a097d7e0d4585bbf82f9b12d7a88630efcadeb8ffdc8b7c8a53fe94eea9d2cd6cf90828c3511fc936222ba845fc77995a03855578"; } ; { a = SHA2_256; entropy_input = "14683ec508a29d7812e0f04a3e9d87897000dc07b4fbcfda58eb7cdabc492e58"; nonce = "b2243e744eb980b3ece25ce76383fd46"; personalization_string = ""; entropy_input_reseed = "18590e0ef4ee2bdae462f76d9324b3002559f74c370cfccf96a571d6955703a7"; additional_input_reseed = "9ea3ccca1e8d791d22fcda621fc4d51b882df32d94ea8f20ee449313e6909b78"; additional_input_1 = "16366a578b5ea4d0cb547790ef5b4fd45d7cd845bc8a7c45e99419c8737debb4"; additional_input_2 = "a68caa29a53f1ba857e484d095805dc319fe6963e4c4daaf355f722eba746b92"; returned_bits = "c4e7532ee816789c2d3da9ff9f4b37139a8515dbf8f9e1d0bf00c12addd79ebbd76236f75f2aa705a09f7955038ebff0d566911c5ea13214e2c2eeb46d23ad86a33b60f7b9448d63eec3e1d59f48b39552857447dc5d7944667a230e3dbfa30ca322f6eacaf7536a286706a627c5083c32de0658b9073857c30fb1d86eb8ad1b"; } ; { a = SHA2_256; entropy_input = "a1d5bb7d70621dee6b668b28c56d5610c2f8ced30284cc3e0e48de331af05062"; nonce = "88a49e3e54c5ea54c98b95de81bcc807"; personalization_string = ""; entropy_input_reseed = "b4e2426e98f6eed97a6cdf690a89ee109e84c3dca16c883c26fa4ac671638d8d"; additional_input_reseed = "5bd1e086ed228cfd8b55c1731fea40c3a63d022599ca2da4bb23118f4821ba62"; additional_input_1 = "b754b53ac226e8ebe47a3d31496ec822de06fca2e7ef5bf1dec6c83d05368ec3"; additional_input_2 = "fa7e76b2805d90b3d89fff545010d84f67aa3a2c9eb2ba232e75f4d53267dac3"; returned_bits = "df6b2460688fa537df3ddfe5575fca5eb8abad56cbc4e5a618a2b4a7daf6e215c3a497974c502f9d0ec35de3fc2ea5d4f10de9b2aee66dcc7e7ae6357983095959b817f0383e3030771bd2ed97406acf78a1a4a5f30fa0992289c9202e69e3eb1eabe227c11409ff430f6dfca1a923a8b17bc4b87e908007f5e9759c41482b01"; } ; { a = SHA2_256; entropy_input = "68f21d14525d56233c7e263482d344c388a840103a77fb20ac60ce463cabdc79"; nonce = "59fa80ae570f3e0c60ac7e2578cec3cb"; personalization_string = ""; entropy_input_reseed = "7584b4166530442f06e241dd904f562167e2fdae3247ab853a4a9d4884a5fa46"; additional_input_reseed = "f6a5482f139045c5389c9246d772c782c4ebf79c3a84b5cf779f458a69a52914"; additional_input_1 = "9d37b1ce99f8079993ddf0bd54bab218016685b22655a678ce4300105f3a45b7"; additional_input_2 = "4c97c67026ff43c2ee730e7b2ce8cce4794fd0588deb16185fa6792ddd0d46de"; returned_bits = "e5f8874be0a8345aabf2f829a7c06bb40e60869508c2bdef071d73692c0265f6a5bf9ca6cf47d75cbd9df88b9cb236cdfce37d2fd4913f177dbd41887dae116edfbdad4fd6e4c1a51aad9f9d6afe7fcafced45a4913d742a7ec00fd6170d63a68f986d8c2357765e4d38835d3fea301afab43a50bd9edd2dec6a979732b25292"; } ; { a = SHA2_256; entropy_input = "1ae12a5e4e9a4a5bfa79da30a9e6c62ffc639572ef1254194d129a16eb53c716"; nonce = "5399b3481fdf24d373222267790a0fec"; personalization_string = "8280cfdcd7a575816e0199e115da0ea77cae9d30b49c891a6c225e9037ba67e2"; entropy_input_reseed = "681554ff702658122e91ba017450cfdfc8e3f4911153f7bcc428403e9c7b9d68"; additional_input_reseed = "226732b7a457cf0ac0ef09fd4f81296573b49a68de5e7ac3070e148c95e8e323"; additional_input_1 = "45942b5e9a1a128e85e12c34596374ddc85fd7502e5633c7390fc6e6f1e5ef56"; additional_input_2 = "6fc59929b41e77072886aff45f737b449b105ed7eacbd74c7cbfedf533dbeaa1"; returned_bits = "b7547332e1509663fcfea2128f7f3a3df484cd8df034b00199157d35d61e35f1a9d481c7d2e81305616d70fc371ee459b0b2267d627e928590edcac3231898b24ef378aa9c3d381619f665379be76c7c1bd535505c563db3725f034786e35bdd90429305fd71d7bf680e8cdd6d4c348d97078f5cf5e89dee2dc410fad4f2a30f"; } ; { a = SHA2_256; entropy_input = "10b8789cdbd6778442a45edf228b9923f452631ad0fe9e608d10826ba71da7ca"; nonce = "159fc5d8e50eb56e22974789b1dc20d1"; personalization_string = "2dd59e37766c667571b779c06e12ba219188489772f48631a6728b5b867e3cf4"; entropy_input_reseed = "966d942038030509b20e610062042b6bf104812818893292a68d57d1ce865151"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "3e6acd8b4e85b4a0f7928f6bd41a8e6b52524fe72723a0509637d33f15afe7d8da6a15209b9e4149576fbb1fd831f784c04439abda4605d06556dc3002055b5855fba201f6daef79f78d001ed69eca8a418513d02464e8d742c2799cd68edfbe88ae9b35a0aa065c42a4770058c4b026d0350a7afa9c52c3c7fa054f8a96d887"; } ; { a = SHA2_256; entropy_input = "e5fa73bed99340c91ab17d039efd248fcd1ab8b0a0f655dd3149949685ecadbd"; nonce = "af4b94f08300a1eb059ad6a687a22fd1"; personalization_string = "d0095a4fd7f6d6de2a1f0b292c47ece8565bf8c202f0723d0de7f2f7904537bf"; entropy_input_reseed = "4dd81fad534aa36e174d06666e95a4d9b3622bf60d8a562c764541ea7c974fe9"; additional_input_reseed = "117ca0aa9d57973005fad1f8a02f2d62ac701758556b42a8d5382ee55540a86b"; additional_input_1 = "a36ba41e095a40f37985a5cd7315f3773132f491ef8a453d3970ae72f41c5365"; additional_input_2 = "abba1d162556eaab729252cd48dead2d7d50a6385b1d270591d465fa38c5597d"; returned_bits = "2bef01bea1fb0ab5fccbb474a1bacb361ffcc326f1d9f1969048c392f2761ed0a37126433311dec9db18596448cb814eda151b264e3ca464b25de401b0e38b43e93c64f675f37ad91e95c24e6997dc4032fa62ba00f3c8a792d6b539a4e8290b10173b6b35f7278f34f40df7c4cf26518350dfa7e24362320c8446963a9a1369"; } ; { a = SHA2_256; entropy_input = "0c2c24287f264c1d5329d18989e7f9ce06b8a9446d26cd90ed718792b13dad94"; nonce = "fd01d038386b37709f8da03579f82bcc"; personalization_string = ""; entropy_input_reseed = "05b523ccf880bfb0da83a05e4eb2ea28cc75a1e4f9e09c8a3959b18622453bdc"; additional_input_reseed = "85e06a8ca3a741821c3a2a8818131675136efd5841cb96e7ddec7943cc169fa3"; additional_input_1 = "6b842e1cfdcc6203fa3750cfb3c722f7a85014c06e78da8ea61f0f9e7c20cb4a"; additional_input_2 = "7ba4a1494a0b498388f94d1726b8baf63e44a03c2bfbbff35ad039b39881720a"; returned_bits = "b1001e78fdb26dc92e2389ec0eb5eb3059f44ab4f2ead6c74a7615ab8687381898f5b0d838247f41786bb83c077713ff84540ed54061f4d00264699df476873c0dd0c363b998054edc64084efeed7dcf28d7719979978448d7dce8f8aa3868e56b89eebf275f000a39c4cfb5af16a64302a90986cc3042d8826f2e3f7fdb859d"; } ; { a = SHA2_256; entropy_input = "c13d6cd63bb7931174696f3e04a0c41cb0b2561134e847ce03e36326b803f8ab"; nonce = "2084ab32374392ea9f6e8a474f18e9d7"; personalization_string = ""; entropy_input_reseed = "aec5a6a7232a52b81ce7e981a359cef1bbd2f1eff8488371468cd1f4147a89c2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "daea78881737cb26d60c36ceb9fec3d281c7aec54b4b9850937b373b2b2621fe077585a1fe88265d84f225552e5c85cbec8d00069648065ac12073aedce8c940460949b597667ecfcedabd7a86a979b904a24d32db10223eae5a98a0d1b6571b8643df2c6265a5d66cee9f4abfc5778146d6fb2b853d82636c1325b2d1ef4576"; } ; { a = SHA2_256; entropy_input = "88a76c16d3270ed3fcd176f9d793fa0c35516574c1cef425b6007628afa35e2b"; nonce = "ff16cf7cb8e49d482cfd3994abc5ef8a"; personalization_string = "9213c54e3d002df8741163ab9d7e0757cd512c691ad64bafef95cb72539b0ac6"; entropy_input_reseed = "493b647ff0b3faa2921f12f8f57b919329f2af2fc1f14576d9df2f8cc2ada7a6"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f1330a85f90037876b3749203e849287444a827f0a58c249ff868fc1adba4dce285e076a1f8ae1da8cf9fe14931e8164186c97a8feaf24583451f116e65f8e432e7ed55a36683120377e23128dca1540fefbf3af1b56d5c74187f5286d0a95fb55931770543060ce8df08f3c1959a1f4fc36b64671e0654fffe70d96d521be21"; } ; { a = SHA2_384; entropy_input = "e8e99ffcf08aad8e50386f5d079d79d3db783a74165c6126b42b3140f744a7c7"; nonce = "23541930c8c772adb62981dbef8d054e"; personalization_string = ""; entropy_input_reseed = "cdcf1c30228904bd7ba31798bfbbd64757aa251ac9a1ae8c20a050670feac59b"; additional_input_reseed = "546e04247d6cb5212a57b62f99e1cca767a5768cf79296f45f0db24732ba6368"; additional_input_1 = "fd45f66c8dede41387373c38674605f3e075c9b7cfc66123a5478b8f8e3ab276"; additional_input_2 = "39911a79c6edbbc805a50d2aa018742094177a8e216d647c64428c00169ab2d6"; returned_bits = "871577ddf34b29e5caf132aa82e1d2f1586b76e39aab62acd02f6d4440908a772ac5f6fd48c5f55f1ebe0e76221ac46b834a8a4f5dd9958721ee053ba3aef1574ebd980a5da6a94693662717ee548af0f921421d1afb814e4d1799d351889d2a1bdd57570a913e428e6613b16e158c1cfed038f6578920d60db73dc10a40da9bc363a0206b4e7e49670eccea866efd9a05bc237042cf052f2a4140f9377e3c6792b88ea06323fcebb99c643fc1c3653758d6866cdb148837fb0fdf77de1564cf"; } ; { a = SHA2_384; entropy_input = "9319148fb7c2389793e9f53cd3b4ad8f1bb75710088f1c9a18434ce13b190da2"; nonce = "11fdc53c13aea33985ba2678e8d86d09"; personalization_string = ""; entropy_input_reseed = "8619290e975f1c50f6606c7027efe9c8438d3209db71edd023af0eb024a282d2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "30c2327eddb5c3942d90006eadccfc26d27b149f195389abba507c0746e41d7fb8cf30c15f2cdff73ff3d77b4ca0d289f0660073f2c73f83ce819a6a7d8fe911fd109778b501357eca73079d86bed0916deede54e2e86eca2c04f3d0706e2a55ff84942cbfee22b5a92d309b84b8dd3decb9f3f2c4b24efb4f382833ffb867b5fe054b21d47db6c52ff52faa13ce2abdf7996e23a8c96bac48c02980d96234e478370027d55ba8752c17c7a1bf6253084654e79c13bacc51c1815c8b647e36cb"; } ; { a = SHA2_384; entropy_input = "f9e25060675e4c5734d818d9c31a0b232474520577e42f8c53f803aee2349f4a"; nonce = "9a62a41cf3f5a9e198dff8c907a35a3f"; personalization_string = ""; entropy_input_reseed = "888a7529909ae36053c75badb44d103118e171784a7b67dc0d7a4e1b1d44391a"; additional_input_reseed = "10a25d0027b1c55f615d3b7c3f235d791a81dfe8215315e0c38fccde27a5d8da"; additional_input_1 = "7b10e25044abd0917490e7f1a8cfd24966803fc9be260f3ab5bf954693f60885"; additional_input_2 = "a3563ec5c089fff127b2a2eaef12bd0cb3b18f3a0999754666113a052fd443f9"; returned_bits = "83b9fef4f31c71aebf3753d0404208678987fc4cb2d293a8ac8a547aed18a7a9e09d8196a07d6e97c909e64aef00d9b9530ca1cd69d65807857d9b30a74924a6be96dd96fc48ad5931892736a77f62f68c3fca75af3e2ea5b2a336f1e080a24fa28f81fd8b1a34d3c8aac650acaad25ed1e00bc44092a13940c821942add18bf0ed70c578c305711b0a4991ec5bddfaecee804619b197fd716aa2e6713c0cf91ea0a6d46a4d0ea80a7f70f4fc75307d342e69d1fdff989808b7500275cd05218"; } ; { a = SHA2_512; entropy_input = "58ebcec4539f4af1b32a854181dd0f512b8c704fa47537096a769eff28c59165"; nonce = "a18226cfc779efc9550f7be02006d83c"; personalization_string = ""; entropy_input_reseed = "230cd6e6909e301d1e99ecd1fff2b2cd00a56c7a684c8907bbb13ce3e9a0cbce"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6f4e86f309f69144603961c5366e4f9b16d10c10593ea689a8e7435a327d2524f4468813ea7f3248d8d4bbe17b175cfc40617149983928b267dc0c4db46d2c17fe8bc0764386758af1a824e12eb897feafc1c7ef66f80ffcd993aa016e139991cde8435ee6bb0de45a7fb61eb1a6beb76e012b848ea003f687537e4bd00ced37efdda66333b53a8dd5220c281fbf68bfd9e72285e78197881efc540da4c1ba80a226013a2d7098d34af4112e7b8c865af15409f6901b952fee4a474e4027051e1dce879ddf5e84f3947dc9b94119d67e6b48ed6fd6b1f813c13d3ff30e121efce7918533925f50c8e381e87ea685f993619bacc9efc0aebc884b450646eeaa5e"; } ; { a = SHA2_512; entropy_input = "e1d2d72e7907e7214cb266f1ef641395e54b39e8365304661b0bee371f324652"; nonce = "8417ffd58420e48ec063de5df4462e39"; personalization_string = ""; entropy_input_reseed = "e6cae1b5f3a3a12faaaf39b98ee592c8d4f56b9d4534add5104b357d788c23ab"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "626a0863321ac75e0b6240ea6a619458634a978245c1533819c97114e63914009c9cab732f1310f60f64f033b00729424228671f33425099820ab108412d460f32c0015b73987e937b9bbdd29e5bfb8dbb6c95d2b69fccbc26b060cf0a5dc0992fb0e76b38bcd64fd7a726714e8c8542d44b2f9c5d2f2f8cb370b95e086b07e88f492f51fe6c288d78b76d0c3a6146c9dfce53e76cdbbd158d2944dd10197247004954d92f6b1df4badeb4bb1c98d7d3da2054e3300f6d8dda8863422e6a042c2d84b2bbed6be88f0704763410771b3786d2f6d968b6c224e0cf535e8d02c178b2e0b90e8a7fca0c431b7f3cf41b0a7c17778fe8c2eeb442c910ba88c7c364cd"; } ; { a = SHA2_512; entropy_input = "47c42df62b4dd570efd3c2722ad39a2df5f969a13f645fd27b5290877ba70916"; nonce = "c591934d4f66000ebf8c508fafc44f75"; personalization_string = "94822903cb5c2003c31c6d072ab0dda435add0de7d8f9d5f08b5cba410d888fd"; entropy_input_reseed = "d16a2c72c63580b9bcf156862214533a47b1686c871a0165604fdd00a412a484"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f78e61b443b5a97b7e493a8ce35a43545290dd33d15ba4bf0ff78f34a25c46c4ff4cd485964cc96e90fe847d9fc9e42d96e4f5aaccf976a84e3e12100c28b0f7addb1c76f89663e11890f09e4beefe928a1e0b304f1d9dd0414cd115a01b641fd69c7071f2ca7c7f2e53560f4e91010ba11948195bc5deb556686feb0bb92fe61b3171e639ef47418f02be37796efdb6920952f3a8c766b52fccfa757e923e38028a84f9be1b802c1fbbbb4aef825f4c5e4fc1bf6e96f33ab90ea486710718c9e4f3247b2a55ccef5a5d342cac757f0b9f90bcdcc8c2ec3a43149bbd3924c85f0b5b7ae42151f4ded826ee6d47849ef4e8af64adf6863982503c23c4a0514ce0"; } ; { a = SHA2_512; entropy_input = "f840c75ce0cdb200a3bd980d6cedf1c7321e5f303cd0446c7afd2d2d66657447"; nonce = "b215333b15d55326bc9bebae6ae36efe"; personalization_string = "6d5ca4b1edf6c0afbdce02ecb30923b2f4f2b33121e21b2ffee964cc7de1abe8"; entropy_input_reseed = "a3a337c6fbeb6a979a4783f2b7f0f0dd6d3a9d3747de639a9047248a04a19f5b"; additional_input_reseed = "f56d2b1584ba2f129c77b29590c4e1dfdab5527b1791e3e445750ca6d4ae3542"; additional_input_1 = "05bd799249411b37b80590d49f3348631b06a2408a61635c70687003a8485302"; additional_input_2 = "12d26ac3b87924cda5d78a3e3c0bd81280e340723643ed1b2ebf2dfd52f5dc43"; returned_bits = "b48c13af7a9b6fa6385a7ee5d2ab97dcebf71a715dc465f413cb0962292df84c9c83c4093309f749359b0a0ddcc13162cb4ab8ff7b3a6336351ed79ebf47730f97accb6a960a9c5c25e0920a06cccc3b3f62b616c15ca18d7e0b5c2e7d8ad2518d1ef0bef515af866893e9378b56deec32825fe0a2c5a9729f658915b99ab22a03b7187e83d2d0f41b9467c8326f7bc87189dd8ade18b3a7edf0c0ea462dc22109ec91294cf8ce69c8cd0c129b423edadda8fbd25f4983a70d75001576a26405188bb0284975203694c318f3aa7fe47ec041bc4c11c9bceb1b131f74adcd72fc4d2813564de6d4711017800377be9e4c579e88464d67ea6e457a30f8f652375a"; } ; { a = SHA2_512; entropy_input = "46dfb4e82fc784ad0094dc81136834e5abc767fff2b876a06b1dbd2508dbed3a"; nonce = "64d40d3886ac152838f6853121fd68b7"; personalization_string = ""; entropy_input_reseed = "329004b8bb439305c4b2dcdd54ca97a4f54cb720a8582cdc03ac26f8a603f3fd"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "1887eb4c57b63109f7e446bf0a6c598de093a6013009503925d620f40cf98c8774a6c4a1affe57f8e6b190d0504ff4c4eb55ba4e8a2642d230ee845ed4e31d8adddb1a21dd45346cbda9884a322e6e8f38a82e888f81264a2e254ec2ad5ad4d60a162287e48bc39776eb57dce88cfe467b042d037d1b06877acc39f31b08b1aa13805fe0440a3506a7f59dc6e2376147acf87b78bbaef4c15b579335794688d142eedc231829a34a5c6976e0c8c4649edc178c8f7d8f9ae92f05e3d54df6e47cf9260a5a582a7d3b0030e9a5de912d0f7e4d3103233dcfa8dc0caeddf12a8502c7d941de883690d47bd1a1b61d723abaf0c31d67136fb427edcaa9526a9dc9fa"; } ; { a = SHA2_512; entropy_input = "12738c0ddd0c9ce0393d2acabdfa592286072a362e332ca3f8c401f01d610026"; nonce = "b983dcfd4af5e451f6efe155fcf3ec14"; personalization_string = ""; entropy_input_reseed = "07c8b69898caec3a1104e2e30b811ea095384cc636b9bd24e0f9837d3b8e0b4c"; additional_input_reseed = "fee06814eab6e55cb799e815d84f07278ec6c12d82dea12e261c5b72d0a4eaa5"; additional_input_1 = "f29287d46d517f090df11af46703d5de778028c787a3aa1e5904ed737b776912"; additional_input_2 = "0ce576cae56c46042ff27f9f11ed88f1ba534cf5f2581e5ad6bb69b642897886"; returned_bits = "6293103d028540484c262770ecf7c47c93e778daeda0a5d17a838a5933871af041ac603d81c4a8d73f4cacff06cee74424b57e8440e83939509ea1861adcaa29332bbce015c2b4d6c74154b52a6de9b4c5ec9edb4f54b7be42142b9be07bec5052b78bbc4bb742ee89f0399071f49a73df87b3fe762d1656346c9e8bf8e4b4b8b55e4e1ff23662b6586bf0f105e9d001f1593c175c9a234cbb17cfdafd90ba85f347cb79b0046fb5715bbf35f08345c8fbc26e4722425f04ba431c48ecffcacf15d09ea5abda92f541e46bb63e3933a2c053be4565275d34fa085baf555f92f446ba5e5d05fa0c63c53042092cb66c406d9b6b36b00e76d51b49b75c36e41e52"; } ; { a = SHA2_512; entropy_input = "6a2baf90d2e8b83355a0230a8fc7237c140f7699f40026e276deaefd4faa8e06"; nonce = "b2eecce638bd9fa485e9c9e0d94c3a78"; personalization_string = "a9ea2c4b2aba1f48f2c71ae1a7fee90e073912c833f2de9c5f802ac2ddc57fbd"; entropy_input_reseed = "820fc963827166de710208a7dc33936471e491fc21fb0119a252b49fefb28a01"; additional_input_reseed = "9a463484d172108807c43c048bd13a72d15b470c3443390774a55572d03f47b1"; additional_input_1 = "d98671978ae14b3531394a0785f78242d4b32eb61cffec6088efb8625693276a"; additional_input_2 = "b9aef32c40b7aa4fd732e4431bedce071e4f64405be1c85de03c7faa0aa7270f"; returned_bits = "f55791fdc9d763c34c0fc4cc457a438496f18f483cc60c493fcd0549812fad792f92381532548a8c2257c6e424fa570af260bd47de92f248f57291fead3a68c94be9dc12a656630622be9b602d4fc5037c29bbb5fa92fed2235186048f652131f845f01ed718baf05957e863239e94a5613aa47dd25d5bc9f170e4047e86ef1eefa60e359f2204a3f453c9b37dcfd9410736ee14e296abcdc185f3ed31d8ad461a81479f957e69c34334a24e22f4a69606db8bca6cb189e7de4b83d8a10461fba1942c83aa2e5f84dced9440f10a54c74153643287313ae7fe1bf23c6abecc55c4a3f5540495b7d29a302d426ee2f13dd9ed7a5a6618724544da63527c702e4c"; } ; { a = SHA2_512; entropy_input = "47139f544af9f6b0b8022bbae5b936a3f4bf8a0f1cd10c8c5fb8bb7363df6411"; nonce = "b99640f70c7b55605f7bee6753f30675"; personalization_string = "0f88357519e8f2c05495c595056e6023460bea47e79f72b113784eb6a77f9f28"; entropy_input_reseed = "83ed7fb5ae85138161fe90b14b15295b11d81b0ecbd9f1838a2858cf9e822886"; additional_input_reseed = "e973ea2d399b9c4ad685411a619b7a5ce6f6568bc66efb8855a69f256829a62d"; additional_input_1 = "1bd8090104b78844f6d615e93b7ae0c921517c97735c0aaa28cdee1eb0a14659"; additional_input_2 = "4d57d04fc0a2adc6ebb618f1236fee0eb00e38ff82137f5e375be00ad1aac35e"; returned_bits = "8c4ce3292ae500557b40e4215665c8db5ccba13fbd2d26ca8d1fdad9dca158371ec0003cf801fd28741a2fd31d15e4c0612c68e19fa4e19c626ce4b0184303f4544c414a6541c7d4ac5e6555d22e21c09a096aa9ec09c902eb67a2de9eba94b719ec1ba4dd5dbafee93fcd5125223eaae0bf0d8e7eb92ea0610cc32b69584c0a1565802028f31e6910021d618e5138137eccab894a5385ca4544fdf20919ef2216a3eaf44fdacc7fe05ce22e565a5ab013cd6c9e0a80b430fa8b72127f84f3a780d4ee92c72901eafc8a21c56dcc687ac4ce464cce068895471b36f7b58987ae3272581f00f8d667085bdeadcb06ffef5b1b329bf1db71ce101a2d694de9e322"; } ; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac94"; } ; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac"; } ; ]
val test_vectors:list vec let test_vectors:list vec =
false
null
false
[ { a = SHA1; entropy_input = "7cad65e5cc2888ae4e960f5d143c1425"; nonce = "fc0785db471cc55e"; personalization_string = ""; entropy_input_reseed = "66451d29cf65d899a281905ff9b29e87"; additional_input_reseed = "800d583b2560d2a2300132ee2d13f19f"; additional_input_1 = "42eae705c2225d212fa0554ac6ac564b"; additional_input_2 = "72081e7e70200f1982c3ad9cb1d3ddbe"; returned_bits = "953e92258be7ff61b97077252ab9835231e366dfa5b635fb889c337562a2641d3aa9e46feeb2a4ea03cb73f1f801594c3cc71d2945c11a52bb0e93419df5d0854ad5f2e36d223c119e145cad507495a7" }; { a = SHA1; entropy_input = "0736a083595a8397cb9e676cb37bfb5a"; nonce = "0b184a6d0a630abb"; personalization_string = "c302503d86a2bde46a0c63561a86cfd9"; entropy_input_reseed = "4b50977033483277647945ffefa109e2"; additional_input_reseed = "4dad813744f54324b3046a85be3cc3c8"; additional_input_1 = "7441fefa60f7ee48ff387b587efcb3e6"; additional_input_2 = "f0d005289a9d3993c44bb750d96cc1bc"; returned_bits = "c03971897b854585994eeb8e3d6b556e1a8df18a7ff88f83e8fe17e6dd9071070a6dbef67cb612acf122caa7f817704b3efc6e1b1fd6c330e0a732abea93c00818e12c504fd8e0b36c88f84a95b49362" }; { a = SHA1; entropy_input = "172054c827aa895fa1239b7a484752f2"; nonce = "edb272c0a98c7592"; personalization_string = "47bc78bfbd1bb7e2dcdbf4ebe42c5293"; entropy_input_reseed = "29f92a0e5d24e19af698877f69a0efb5"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6464bdaed23245db1f6510f8659e1b19881d606220997b837684a7f88a166cb75ce6829cb3f11e55d2b7ad349cc1f4ba02e30a76f970613aa74635b0034f8e985cde4f1fddb964657a169386e20767d1" }; { a = SHA1; entropy_input = "b1a19bb07c30ca4f49dc69130d23c0a7"; nonce = "2c06067297058ec5"; personalization_string = ""; entropy_input_reseed = "840802cea2e55a3b1e487bb7aee62b42"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f41bb7ae532344a90d413b66a94ee1d0254a5d5e974e36b1993b1042586f54728d1ebb7c5d351558ed675177e432360708c008984c41bc4c828d83ddeca9ef8ecd9da880a135400a43f91f4ca6d59d00" }; { a = SHA1; entropy_input = "343f9dde89a9e3ecc4f9653c8b392dab"; nonce = "c4fb3606d8f62db1"; personalization_string = ""; entropy_input_reseed = "021fc3ead46ff8bda3b79701b7893a39"; additional_input_reseed = "8918831e15d430616f4bd91046fe0930"; additional_input_1 = "a8772304a1accb16662218a748bb4fd8"; additional_input_2 = "4bf9f2b9d15ec3071ff3674ad7418759"; returned_bits = "9782b2111c985bcaab0b8905ad9bcb97eb3f3554c68d79ee5ca1dcfbd0d7850f65090c79d21d1c6253cf493f08392cfb60461fbc20beb4cf3e022123816f0bc597abebc775633db324c7c1c7cd5e8c56" }; { a = SHA1; entropy_input = "0a086726f66f2ac9e7daa61908f63319"; nonce = "debf011d406a5b23"; personalization_string = "58582da74f8f91db0444beae39016857"; entropy_input_reseed = "c92ba2900ab0a4ca3553806392b6b3e5"; additional_input_reseed = "5604a76e74ef4b304466f21df57c70f3"; additional_input_1 = "e1e4d0754cc306a1752b50c5c446a3d0"; additional_input_2 = "71dacf61875cbf3655e4f7d2e081d493"; returned_bits = "afbb3a05e753f6ebf026594a03b22b3f032edb873b9e1e22532e360a097d7e0d4585bbf82f9b12d7a88630efcadeb8ffdc8b7c8a53fe94eea9d2cd6cf90828c3511fc936222ba845fc77995a03855578" }; { a = SHA2_256; entropy_input = "14683ec508a29d7812e0f04a3e9d87897000dc07b4fbcfda58eb7cdabc492e58"; nonce = "b2243e744eb980b3ece25ce76383fd46"; personalization_string = ""; entropy_input_reseed = "18590e0ef4ee2bdae462f76d9324b3002559f74c370cfccf96a571d6955703a7"; additional_input_reseed = "9ea3ccca1e8d791d22fcda621fc4d51b882df32d94ea8f20ee449313e6909b78"; additional_input_1 = "16366a578b5ea4d0cb547790ef5b4fd45d7cd845bc8a7c45e99419c8737debb4"; additional_input_2 = "a68caa29a53f1ba857e484d095805dc319fe6963e4c4daaf355f722eba746b92"; returned_bits = "c4e7532ee816789c2d3da9ff9f4b37139a8515dbf8f9e1d0bf00c12addd79ebbd76236f75f2aa705a09f7955038ebff0d566911c5ea13214e2c2eeb46d23ad86a33b60f7b9448d63eec3e1d59f48b39552857447dc5d7944667a230e3dbfa30ca322f6eacaf7536a286706a627c5083c32de0658b9073857c30fb1d86eb8ad1b" }; { a = SHA2_256; entropy_input = "a1d5bb7d70621dee6b668b28c56d5610c2f8ced30284cc3e0e48de331af05062"; nonce = "88a49e3e54c5ea54c98b95de81bcc807"; personalization_string = ""; entropy_input_reseed = "b4e2426e98f6eed97a6cdf690a89ee109e84c3dca16c883c26fa4ac671638d8d"; additional_input_reseed = "5bd1e086ed228cfd8b55c1731fea40c3a63d022599ca2da4bb23118f4821ba62"; additional_input_1 = "b754b53ac226e8ebe47a3d31496ec822de06fca2e7ef5bf1dec6c83d05368ec3"; additional_input_2 = "fa7e76b2805d90b3d89fff545010d84f67aa3a2c9eb2ba232e75f4d53267dac3"; returned_bits = "df6b2460688fa537df3ddfe5575fca5eb8abad56cbc4e5a618a2b4a7daf6e215c3a497974c502f9d0ec35de3fc2ea5d4f10de9b2aee66dcc7e7ae6357983095959b817f0383e3030771bd2ed97406acf78a1a4a5f30fa0992289c9202e69e3eb1eabe227c11409ff430f6dfca1a923a8b17bc4b87e908007f5e9759c41482b01" }; { a = SHA2_256; entropy_input = "68f21d14525d56233c7e263482d344c388a840103a77fb20ac60ce463cabdc79"; nonce = "59fa80ae570f3e0c60ac7e2578cec3cb"; personalization_string = ""; entropy_input_reseed = "7584b4166530442f06e241dd904f562167e2fdae3247ab853a4a9d4884a5fa46"; additional_input_reseed = "f6a5482f139045c5389c9246d772c782c4ebf79c3a84b5cf779f458a69a52914"; additional_input_1 = "9d37b1ce99f8079993ddf0bd54bab218016685b22655a678ce4300105f3a45b7"; additional_input_2 = "4c97c67026ff43c2ee730e7b2ce8cce4794fd0588deb16185fa6792ddd0d46de"; returned_bits = "e5f8874be0a8345aabf2f829a7c06bb40e60869508c2bdef071d73692c0265f6a5bf9ca6cf47d75cbd9df88b9cb236cdfce37d2fd4913f177dbd41887dae116edfbdad4fd6e4c1a51aad9f9d6afe7fcafced45a4913d742a7ec00fd6170d63a68f986d8c2357765e4d38835d3fea301afab43a50bd9edd2dec6a979732b25292" }; { a = SHA2_256; entropy_input = "1ae12a5e4e9a4a5bfa79da30a9e6c62ffc639572ef1254194d129a16eb53c716"; nonce = "5399b3481fdf24d373222267790a0fec"; personalization_string = "8280cfdcd7a575816e0199e115da0ea77cae9d30b49c891a6c225e9037ba67e2"; entropy_input_reseed = "681554ff702658122e91ba017450cfdfc8e3f4911153f7bcc428403e9c7b9d68"; additional_input_reseed = "226732b7a457cf0ac0ef09fd4f81296573b49a68de5e7ac3070e148c95e8e323"; additional_input_1 = "45942b5e9a1a128e85e12c34596374ddc85fd7502e5633c7390fc6e6f1e5ef56"; additional_input_2 = "6fc59929b41e77072886aff45f737b449b105ed7eacbd74c7cbfedf533dbeaa1"; returned_bits = "b7547332e1509663fcfea2128f7f3a3df484cd8df034b00199157d35d61e35f1a9d481c7d2e81305616d70fc371ee459b0b2267d627e928590edcac3231898b24ef378aa9c3d381619f665379be76c7c1bd535505c563db3725f034786e35bdd90429305fd71d7bf680e8cdd6d4c348d97078f5cf5e89dee2dc410fad4f2a30f" }; { a = SHA2_256; entropy_input = "10b8789cdbd6778442a45edf228b9923f452631ad0fe9e608d10826ba71da7ca"; nonce = "159fc5d8e50eb56e22974789b1dc20d1"; personalization_string = "2dd59e37766c667571b779c06e12ba219188489772f48631a6728b5b867e3cf4"; entropy_input_reseed = "966d942038030509b20e610062042b6bf104812818893292a68d57d1ce865151"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "3e6acd8b4e85b4a0f7928f6bd41a8e6b52524fe72723a0509637d33f15afe7d8da6a15209b9e4149576fbb1fd831f784c04439abda4605d06556dc3002055b5855fba201f6daef79f78d001ed69eca8a418513d02464e8d742c2799cd68edfbe88ae9b35a0aa065c42a4770058c4b026d0350a7afa9c52c3c7fa054f8a96d887" }; { a = SHA2_256; entropy_input = "e5fa73bed99340c91ab17d039efd248fcd1ab8b0a0f655dd3149949685ecadbd"; nonce = "af4b94f08300a1eb059ad6a687a22fd1"; personalization_string = "d0095a4fd7f6d6de2a1f0b292c47ece8565bf8c202f0723d0de7f2f7904537bf"; entropy_input_reseed = "4dd81fad534aa36e174d06666e95a4d9b3622bf60d8a562c764541ea7c974fe9"; additional_input_reseed = "117ca0aa9d57973005fad1f8a02f2d62ac701758556b42a8d5382ee55540a86b"; additional_input_1 = "a36ba41e095a40f37985a5cd7315f3773132f491ef8a453d3970ae72f41c5365"; additional_input_2 = "abba1d162556eaab729252cd48dead2d7d50a6385b1d270591d465fa38c5597d"; returned_bits = "2bef01bea1fb0ab5fccbb474a1bacb361ffcc326f1d9f1969048c392f2761ed0a37126433311dec9db18596448cb814eda151b264e3ca464b25de401b0e38b43e93c64f675f37ad91e95c24e6997dc4032fa62ba00f3c8a792d6b539a4e8290b10173b6b35f7278f34f40df7c4cf26518350dfa7e24362320c8446963a9a1369" }; { a = SHA2_256; entropy_input = "0c2c24287f264c1d5329d18989e7f9ce06b8a9446d26cd90ed718792b13dad94"; nonce = "fd01d038386b37709f8da03579f82bcc"; personalization_string = ""; entropy_input_reseed = "05b523ccf880bfb0da83a05e4eb2ea28cc75a1e4f9e09c8a3959b18622453bdc"; additional_input_reseed = "85e06a8ca3a741821c3a2a8818131675136efd5841cb96e7ddec7943cc169fa3"; additional_input_1 = "6b842e1cfdcc6203fa3750cfb3c722f7a85014c06e78da8ea61f0f9e7c20cb4a"; additional_input_2 = "7ba4a1494a0b498388f94d1726b8baf63e44a03c2bfbbff35ad039b39881720a"; returned_bits = "b1001e78fdb26dc92e2389ec0eb5eb3059f44ab4f2ead6c74a7615ab8687381898f5b0d838247f41786bb83c077713ff84540ed54061f4d00264699df476873c0dd0c363b998054edc64084efeed7dcf28d7719979978448d7dce8f8aa3868e56b89eebf275f000a39c4cfb5af16a64302a90986cc3042d8826f2e3f7fdb859d" }; { a = SHA2_256; entropy_input = "c13d6cd63bb7931174696f3e04a0c41cb0b2561134e847ce03e36326b803f8ab"; nonce = "2084ab32374392ea9f6e8a474f18e9d7"; personalization_string = ""; entropy_input_reseed = "aec5a6a7232a52b81ce7e981a359cef1bbd2f1eff8488371468cd1f4147a89c2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "daea78881737cb26d60c36ceb9fec3d281c7aec54b4b9850937b373b2b2621fe077585a1fe88265d84f225552e5c85cbec8d00069648065ac12073aedce8c940460949b597667ecfcedabd7a86a979b904a24d32db10223eae5a98a0d1b6571b8643df2c6265a5d66cee9f4abfc5778146d6fb2b853d82636c1325b2d1ef4576" }; { a = SHA2_256; entropy_input = "88a76c16d3270ed3fcd176f9d793fa0c35516574c1cef425b6007628afa35e2b"; nonce = "ff16cf7cb8e49d482cfd3994abc5ef8a"; personalization_string = "9213c54e3d002df8741163ab9d7e0757cd512c691ad64bafef95cb72539b0ac6"; entropy_input_reseed = "493b647ff0b3faa2921f12f8f57b919329f2af2fc1f14576d9df2f8cc2ada7a6"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f1330a85f90037876b3749203e849287444a827f0a58c249ff868fc1adba4dce285e076a1f8ae1da8cf9fe14931e8164186c97a8feaf24583451f116e65f8e432e7ed55a36683120377e23128dca1540fefbf3af1b56d5c74187f5286d0a95fb55931770543060ce8df08f3c1959a1f4fc36b64671e0654fffe70d96d521be21" }; { a = SHA2_384; entropy_input = "e8e99ffcf08aad8e50386f5d079d79d3db783a74165c6126b42b3140f744a7c7"; nonce = "23541930c8c772adb62981dbef8d054e"; personalization_string = ""; entropy_input_reseed = "cdcf1c30228904bd7ba31798bfbbd64757aa251ac9a1ae8c20a050670feac59b"; additional_input_reseed = "546e04247d6cb5212a57b62f99e1cca767a5768cf79296f45f0db24732ba6368"; additional_input_1 = "fd45f66c8dede41387373c38674605f3e075c9b7cfc66123a5478b8f8e3ab276"; additional_input_2 = "39911a79c6edbbc805a50d2aa018742094177a8e216d647c64428c00169ab2d6"; returned_bits = "871577ddf34b29e5caf132aa82e1d2f1586b76e39aab62acd02f6d4440908a772ac5f6fd48c5f55f1ebe0e76221ac46b834a8a4f5dd9958721ee053ba3aef1574ebd980a5da6a94693662717ee548af0f921421d1afb814e4d1799d351889d2a1bdd57570a913e428e6613b16e158c1cfed038f6578920d60db73dc10a40da9bc363a0206b4e7e49670eccea866efd9a05bc237042cf052f2a4140f9377e3c6792b88ea06323fcebb99c643fc1c3653758d6866cdb148837fb0fdf77de1564cf" }; { a = SHA2_384; entropy_input = "9319148fb7c2389793e9f53cd3b4ad8f1bb75710088f1c9a18434ce13b190da2"; nonce = "11fdc53c13aea33985ba2678e8d86d09"; personalization_string = ""; entropy_input_reseed = "8619290e975f1c50f6606c7027efe9c8438d3209db71edd023af0eb024a282d2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "30c2327eddb5c3942d90006eadccfc26d27b149f195389abba507c0746e41d7fb8cf30c15f2cdff73ff3d77b4ca0d289f0660073f2c73f83ce819a6a7d8fe911fd109778b501357eca73079d86bed0916deede54e2e86eca2c04f3d0706e2a55ff84942cbfee22b5a92d309b84b8dd3decb9f3f2c4b24efb4f382833ffb867b5fe054b21d47db6c52ff52faa13ce2abdf7996e23a8c96bac48c02980d96234e478370027d55ba8752c17c7a1bf6253084654e79c13bacc51c1815c8b647e36cb" }; { a = SHA2_384; entropy_input = "f9e25060675e4c5734d818d9c31a0b232474520577e42f8c53f803aee2349f4a"; nonce = "9a62a41cf3f5a9e198dff8c907a35a3f"; personalization_string = ""; entropy_input_reseed = "888a7529909ae36053c75badb44d103118e171784a7b67dc0d7a4e1b1d44391a"; additional_input_reseed = "10a25d0027b1c55f615d3b7c3f235d791a81dfe8215315e0c38fccde27a5d8da"; additional_input_1 = "7b10e25044abd0917490e7f1a8cfd24966803fc9be260f3ab5bf954693f60885"; additional_input_2 = "a3563ec5c089fff127b2a2eaef12bd0cb3b18f3a0999754666113a052fd443f9"; returned_bits = "83b9fef4f31c71aebf3753d0404208678987fc4cb2d293a8ac8a547aed18a7a9e09d8196a07d6e97c909e64aef00d9b9530ca1cd69d65807857d9b30a74924a6be96dd96fc48ad5931892736a77f62f68c3fca75af3e2ea5b2a336f1e080a24fa28f81fd8b1a34d3c8aac650acaad25ed1e00bc44092a13940c821942add18bf0ed70c578c305711b0a4991ec5bddfaecee804619b197fd716aa2e6713c0cf91ea0a6d46a4d0ea80a7f70f4fc75307d342e69d1fdff989808b7500275cd05218" }; { a = SHA2_512; entropy_input = "58ebcec4539f4af1b32a854181dd0f512b8c704fa47537096a769eff28c59165"; nonce = "a18226cfc779efc9550f7be02006d83c"; personalization_string = ""; entropy_input_reseed = "230cd6e6909e301d1e99ecd1fff2b2cd00a56c7a684c8907bbb13ce3e9a0cbce"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6f4e86f309f69144603961c5366e4f9b16d10c10593ea689a8e7435a327d2524f4468813ea7f3248d8d4bbe17b175cfc40617149983928b267dc0c4db46d2c17fe8bc0764386758af1a824e12eb897feafc1c7ef66f80ffcd993aa016e139991cde8435ee6bb0de45a7fb61eb1a6beb76e012b848ea003f687537e4bd00ced37efdda66333b53a8dd5220c281fbf68bfd9e72285e78197881efc540da4c1ba80a226013a2d7098d34af4112e7b8c865af15409f6901b952fee4a474e4027051e1dce879ddf5e84f3947dc9b94119d67e6b48ed6fd6b1f813c13d3ff30e121efce7918533925f50c8e381e87ea685f993619bacc9efc0aebc884b450646eeaa5e" }; { a = SHA2_512; entropy_input = "e1d2d72e7907e7214cb266f1ef641395e54b39e8365304661b0bee371f324652"; nonce = "8417ffd58420e48ec063de5df4462e39"; personalization_string = ""; entropy_input_reseed = "e6cae1b5f3a3a12faaaf39b98ee592c8d4f56b9d4534add5104b357d788c23ab"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "626a0863321ac75e0b6240ea6a619458634a978245c1533819c97114e63914009c9cab732f1310f60f64f033b00729424228671f33425099820ab108412d460f32c0015b73987e937b9bbdd29e5bfb8dbb6c95d2b69fccbc26b060cf0a5dc0992fb0e76b38bcd64fd7a726714e8c8542d44b2f9c5d2f2f8cb370b95e086b07e88f492f51fe6c288d78b76d0c3a6146c9dfce53e76cdbbd158d2944dd10197247004954d92f6b1df4badeb4bb1c98d7d3da2054e3300f6d8dda8863422e6a042c2d84b2bbed6be88f0704763410771b3786d2f6d968b6c224e0cf535e8d02c178b2e0b90e8a7fca0c431b7f3cf41b0a7c17778fe8c2eeb442c910ba88c7c364cd" }; { a = SHA2_512; entropy_input = "47c42df62b4dd570efd3c2722ad39a2df5f969a13f645fd27b5290877ba70916"; nonce = "c591934d4f66000ebf8c508fafc44f75"; personalization_string = "94822903cb5c2003c31c6d072ab0dda435add0de7d8f9d5f08b5cba410d888fd"; entropy_input_reseed = "d16a2c72c63580b9bcf156862214533a47b1686c871a0165604fdd00a412a484"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f78e61b443b5a97b7e493a8ce35a43545290dd33d15ba4bf0ff78f34a25c46c4ff4cd485964cc96e90fe847d9fc9e42d96e4f5aaccf976a84e3e12100c28b0f7addb1c76f89663e11890f09e4beefe928a1e0b304f1d9dd0414cd115a01b641fd69c7071f2ca7c7f2e53560f4e91010ba11948195bc5deb556686feb0bb92fe61b3171e639ef47418f02be37796efdb6920952f3a8c766b52fccfa757e923e38028a84f9be1b802c1fbbbb4aef825f4c5e4fc1bf6e96f33ab90ea486710718c9e4f3247b2a55ccef5a5d342cac757f0b9f90bcdcc8c2ec3a43149bbd3924c85f0b5b7ae42151f4ded826ee6d47849ef4e8af64adf6863982503c23c4a0514ce0" }; { a = SHA2_512; entropy_input = "f840c75ce0cdb200a3bd980d6cedf1c7321e5f303cd0446c7afd2d2d66657447"; nonce = "b215333b15d55326bc9bebae6ae36efe"; personalization_string = "6d5ca4b1edf6c0afbdce02ecb30923b2f4f2b33121e21b2ffee964cc7de1abe8"; entropy_input_reseed = "a3a337c6fbeb6a979a4783f2b7f0f0dd6d3a9d3747de639a9047248a04a19f5b"; additional_input_reseed = "f56d2b1584ba2f129c77b29590c4e1dfdab5527b1791e3e445750ca6d4ae3542"; additional_input_1 = "05bd799249411b37b80590d49f3348631b06a2408a61635c70687003a8485302"; additional_input_2 = "12d26ac3b87924cda5d78a3e3c0bd81280e340723643ed1b2ebf2dfd52f5dc43"; returned_bits = "b48c13af7a9b6fa6385a7ee5d2ab97dcebf71a715dc465f413cb0962292df84c9c83c4093309f749359b0a0ddcc13162cb4ab8ff7b3a6336351ed79ebf47730f97accb6a960a9c5c25e0920a06cccc3b3f62b616c15ca18d7e0b5c2e7d8ad2518d1ef0bef515af866893e9378b56deec32825fe0a2c5a9729f658915b99ab22a03b7187e83d2d0f41b9467c8326f7bc87189dd8ade18b3a7edf0c0ea462dc22109ec91294cf8ce69c8cd0c129b423edadda8fbd25f4983a70d75001576a26405188bb0284975203694c318f3aa7fe47ec041bc4c11c9bceb1b131f74adcd72fc4d2813564de6d4711017800377be9e4c579e88464d67ea6e457a30f8f652375a" }; { a = SHA2_512; entropy_input = "46dfb4e82fc784ad0094dc81136834e5abc767fff2b876a06b1dbd2508dbed3a"; nonce = "64d40d3886ac152838f6853121fd68b7"; personalization_string = ""; entropy_input_reseed = "329004b8bb439305c4b2dcdd54ca97a4f54cb720a8582cdc03ac26f8a603f3fd"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "1887eb4c57b63109f7e446bf0a6c598de093a6013009503925d620f40cf98c8774a6c4a1affe57f8e6b190d0504ff4c4eb55ba4e8a2642d230ee845ed4e31d8adddb1a21dd45346cbda9884a322e6e8f38a82e888f81264a2e254ec2ad5ad4d60a162287e48bc39776eb57dce88cfe467b042d037d1b06877acc39f31b08b1aa13805fe0440a3506a7f59dc6e2376147acf87b78bbaef4c15b579335794688d142eedc231829a34a5c6976e0c8c4649edc178c8f7d8f9ae92f05e3d54df6e47cf9260a5a582a7d3b0030e9a5de912d0f7e4d3103233dcfa8dc0caeddf12a8502c7d941de883690d47bd1a1b61d723abaf0c31d67136fb427edcaa9526a9dc9fa" }; { a = SHA2_512; entropy_input = "12738c0ddd0c9ce0393d2acabdfa592286072a362e332ca3f8c401f01d610026"; nonce = "b983dcfd4af5e451f6efe155fcf3ec14"; personalization_string = ""; entropy_input_reseed = "07c8b69898caec3a1104e2e30b811ea095384cc636b9bd24e0f9837d3b8e0b4c"; additional_input_reseed = "fee06814eab6e55cb799e815d84f07278ec6c12d82dea12e261c5b72d0a4eaa5"; additional_input_1 = "f29287d46d517f090df11af46703d5de778028c787a3aa1e5904ed737b776912"; additional_input_2 = "0ce576cae56c46042ff27f9f11ed88f1ba534cf5f2581e5ad6bb69b642897886"; returned_bits = "6293103d028540484c262770ecf7c47c93e778daeda0a5d17a838a5933871af041ac603d81c4a8d73f4cacff06cee74424b57e8440e83939509ea1861adcaa29332bbce015c2b4d6c74154b52a6de9b4c5ec9edb4f54b7be42142b9be07bec5052b78bbc4bb742ee89f0399071f49a73df87b3fe762d1656346c9e8bf8e4b4b8b55e4e1ff23662b6586bf0f105e9d001f1593c175c9a234cbb17cfdafd90ba85f347cb79b0046fb5715bbf35f08345c8fbc26e4722425f04ba431c48ecffcacf15d09ea5abda92f541e46bb63e3933a2c053be4565275d34fa085baf555f92f446ba5e5d05fa0c63c53042092cb66c406d9b6b36b00e76d51b49b75c36e41e52" }; { a = SHA2_512; entropy_input = "6a2baf90d2e8b83355a0230a8fc7237c140f7699f40026e276deaefd4faa8e06"; nonce = "b2eecce638bd9fa485e9c9e0d94c3a78"; personalization_string = "a9ea2c4b2aba1f48f2c71ae1a7fee90e073912c833f2de9c5f802ac2ddc57fbd"; entropy_input_reseed = "820fc963827166de710208a7dc33936471e491fc21fb0119a252b49fefb28a01"; additional_input_reseed = "9a463484d172108807c43c048bd13a72d15b470c3443390774a55572d03f47b1"; additional_input_1 = "d98671978ae14b3531394a0785f78242d4b32eb61cffec6088efb8625693276a"; additional_input_2 = "b9aef32c40b7aa4fd732e4431bedce071e4f64405be1c85de03c7faa0aa7270f"; returned_bits = "f55791fdc9d763c34c0fc4cc457a438496f18f483cc60c493fcd0549812fad792f92381532548a8c2257c6e424fa570af260bd47de92f248f57291fead3a68c94be9dc12a656630622be9b602d4fc5037c29bbb5fa92fed2235186048f652131f845f01ed718baf05957e863239e94a5613aa47dd25d5bc9f170e4047e86ef1eefa60e359f2204a3f453c9b37dcfd9410736ee14e296abcdc185f3ed31d8ad461a81479f957e69c34334a24e22f4a69606db8bca6cb189e7de4b83d8a10461fba1942c83aa2e5f84dced9440f10a54c74153643287313ae7fe1bf23c6abecc55c4a3f5540495b7d29a302d426ee2f13dd9ed7a5a6618724544da63527c702e4c" }; { a = SHA2_512; entropy_input = "47139f544af9f6b0b8022bbae5b936a3f4bf8a0f1cd10c8c5fb8bb7363df6411"; nonce = "b99640f70c7b55605f7bee6753f30675"; personalization_string = "0f88357519e8f2c05495c595056e6023460bea47e79f72b113784eb6a77f9f28"; entropy_input_reseed = "83ed7fb5ae85138161fe90b14b15295b11d81b0ecbd9f1838a2858cf9e822886"; additional_input_reseed = "e973ea2d399b9c4ad685411a619b7a5ce6f6568bc66efb8855a69f256829a62d"; additional_input_1 = "1bd8090104b78844f6d615e93b7ae0c921517c97735c0aaa28cdee1eb0a14659"; additional_input_2 = "4d57d04fc0a2adc6ebb618f1236fee0eb00e38ff82137f5e375be00ad1aac35e"; returned_bits = "8c4ce3292ae500557b40e4215665c8db5ccba13fbd2d26ca8d1fdad9dca158371ec0003cf801fd28741a2fd31d15e4c0612c68e19fa4e19c626ce4b0184303f4544c414a6541c7d4ac5e6555d22e21c09a096aa9ec09c902eb67a2de9eba94b719ec1ba4dd5dbafee93fcd5125223eaae0bf0d8e7eb92ea0610cc32b69584c0a1565802028f31e6910021d618e5138137eccab894a5385ca4544fdf20919ef2216a3eaf44fdacc7fe05ce22e565a5ab013cd6c9e0a80b430fa8b72127f84f3a780d4ee92c72901eafc8a21c56dcc687ac4ce464cce068895471b36f7b58987ae3272581f00f8d667085bdeadcb06ffef5b1b329bf1db71ce101a2d694de9e322" }; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac94" }; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac" } ]
{ "checked_file": "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Meta.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Spec.HMAC_DRBG.Test.Vectors.fst" }
[ "total" ]
[ "Prims.Cons", "Spec.HMAC_DRBG.Test.Vectors.vec", "Spec.HMAC_DRBG.Test.Vectors.Mkvec", "Spec.Hash.Definitions.SHA1", "Spec.Hash.Definitions.SHA2_256", "Spec.Hash.Definitions.SHA2_384", "Spec.Hash.Definitions.SHA2_512", "Prims.Nil" ]
[]
module Spec.HMAC_DRBG.Test.Vectors open Lib.Meta open Spec.Hash.Definitions #set-options "--fuel 0 --ifuel 0" /// /// HMAC-DRBG test vectors from NIST CAVP /// https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators#DRBG /// let is_supported_alg = function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false let supported_alg = a:hash_alg{ is_supported_alg a } type vec = { a: supported_alg; entropy_input: hex_string; nonce: hex_string; personalization_string: hex_string; entropy_input_reseed: hex_string; additional_input_reseed: hex_string; additional_input_1: hex_string; additional_input_2: hex_string; returned_bits: hex_string; }
false
true
Spec.HMAC_DRBG.Test.Vectors.fst
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_vectors:list vec
[]
Spec.HMAC_DRBG.Test.Vectors.test_vectors
{ "file_name": "specs/drbg/Spec.HMAC_DRBG.Test.Vectors.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.list Spec.HMAC_DRBG.Test.Vectors.vec
{ "end_col": 1, "end_line": 312, "start_col": 30, "start_line": 31 }
Prims.Tot
val ___UINT32BE:eqtype
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "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 ___UINT32BE : eqtype = U32.t
val ___UINT32BE:eqtype let ___UINT32BE:eqtype =
false
null
false
U32.t
{ "checked_file": "EverParse3d.Prelude.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ "total" ]
[ "FStar.UInt32.t" ]
[]
(* Copyright 2019 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 EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE
false
true
EverParse3d.Prelude.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ___UINT32BE:eqtype
[]
EverParse3d.Prelude.___UINT32BE
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
Prims.eqtype
{ "end_col": 32, "end_line": 209, "start_col": 27, "start_line": 209 }