file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
FStar.Modifies.fst
FStar.Modifies.buffer_live_mreference_unused_in_disjoint
val buffer_live_mreference_unused_in_disjoint (#t1: Type) (#t2: Type) (#pre: Preorder.preorder t2) (h: HS.mem) (b1: B.buffer t1) (b2: HS.mreference t2 pre) : Lemma (requires (B.live h b1 /\ HS.unused_in b2 h)) (ensures (loc_disjoint (loc_buffer b1) (loc_freed_mreference b2))) [SMTPat (B.live h b1); SMTPat (HS.unused_in b2 h)]
val buffer_live_mreference_unused_in_disjoint (#t1: Type) (#t2: Type) (#pre: Preorder.preorder t2) (h: HS.mem) (b1: B.buffer t1) (b2: HS.mreference t2 pre) : Lemma (requires (B.live h b1 /\ HS.unused_in b2 h)) (ensures (loc_disjoint (loc_buffer b1) (loc_freed_mreference b2))) [SMTPat (B.live h b1); SMTPat (HS.unused_in b2 h)]
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)
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 129, "end_line": 416, "start_col": 0, "start_line": 415 }
(* 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)
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
h: FStar.Monotonic.HyperStack.mem -> b1: FStar.Buffer.buffer t1 -> b2: FStar.Monotonic.HyperStack.mreference t2 pre -> FStar.Pervasives.Lemma (requires FStar.Buffer.live h b1 /\ FStar.Monotonic.HyperStack.unused_in b2 h) (ensures FStar.Modifies.loc_disjoint (FStar.Modifies.loc_buffer b1) (FStar.Modifies.loc_freed_mreference b2)) [SMTPat (FStar.Buffer.live h b1); SMTPat (FStar.Monotonic.HyperStack.unused_in b2 h)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mreference", "FStar.Modifies.loc_disjoint_includes", "FStar.Modifies.loc_freed_mreference", "FStar.Buffer.lseq", "FStar.Buffer.max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.content", "FStar.Modifies.loc_buffer", "Prims.unit" ]
[]
true
false
true
false
false
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)
false
FStar.Modifies.fst
FStar.Modifies.modifies_free
val modifies_free (#a: Type) (#rel: Preorder.preorder a) (r: HS.mreference a rel { HS.is_mm r } ) (m: HS.mem { m `HS.contains` r } ) : Lemma (modifies (loc_freed_mreference r) m (HS.free r m))
val modifies_free (#a: Type) (#rel: Preorder.preorder a) (r: HS.mreference a rel { HS.is_mm r } ) (m: HS.mem { m `HS.contains` r } ) : Lemma (modifies (loc_freed_mreference r) m (HS.free r m))
let modifies_free = MG.modifies_free #_ #cls
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 324, "start_col": 0, "start_line": 324 }
(* 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
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
r: FStar.Monotonic.HyperStack.mreference a rel {FStar.Monotonic.HyperStack.is_mm r} -> m: FStar.Monotonic.HyperStack.mem{FStar.Monotonic.HyperStack.contains m r} -> FStar.Pervasives.Lemma (ensures FStar.Modifies.modifies (FStar.Modifies.loc_freed_mreference r) m (FStar.Monotonic.HyperStack.free r m))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.modifies_free", "FStar.Modifies.aloc", "FStar.Modifies.cls" ]
[]
true
false
true
false
false
let modifies_free =
MG.modifies_free #_ #cls
false
FStar.Modifies.fst
FStar.Modifies.modifies_buffer_none_modifies
val modifies_buffer_none_modifies (h1 h2: HS.mem) : Lemma (requires (B.modifies_none h1 h2)) (ensures (modifies loc_none h1 h2))
val modifies_buffer_none_modifies (h1 h2: HS.mem) : Lemma (requires (B.modifies_none h1 h2)) (ensures (modifies loc_none h1 h2))
let modifies_buffer_none_modifies h1 h2 = MG.modifies_none_intro #_ #cls h1 h2 (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ())
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 332, "start_col": 0, "start_line": 328 }
(* 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
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.Buffer.modifies_none h1 h2) (ensures FStar.Modifies.modifies FStar.Modifies.loc_none h1 h2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.ModifiesGen.modifies_none_intro", "FStar.Modifies.aloc", "FStar.Modifies.cls", "FStar.Monotonic.HyperHeap.rid", "Prims.unit", "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mreference", "Prims.nat" ]
[]
false
false
true
false
false
let modifies_buffer_none_modifies h1 h2 =
MG.modifies_none_intro #_ #cls h1 h2 (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ())
false
FStar.Modifies.fst
FStar.Modifies.not_live_region_does_not_contain_addr
val not_live_region_does_not_contain_addr (h: HS.mem) (ra: HS.rid * nat) : Lemma (requires (~ (HS.live_region h (fst ra)))) (ensures (h `does_not_contain_addr` ra))
val not_live_region_does_not_contain_addr (h: HS.mem) (ra: HS.rid * nat) : Lemma (requires (~ (HS.live_region h (fst ra)))) (ensures (h `does_not_contain_addr` ra))
let not_live_region_does_not_contain_addr = MG.not_live_region_does_not_contain_addr
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 84, "end_line": 420, "start_col": 0, "start_line": 420 }
(* 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
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
h: FStar.Monotonic.HyperStack.mem -> ra: (FStar.Monotonic.HyperHeap.rid * Prims.nat) -> FStar.Pervasives.Lemma (requires ~(FStar.Monotonic.HyperStack.live_region h (FStar.Pervasives.Native.fst ra))) (ensures FStar.Modifies.does_not_contain_addr h ra)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.not_live_region_does_not_contain_addr" ]
[]
true
false
true
false
false
let not_live_region_does_not_contain_addr =
MG.not_live_region_does_not_contain_addr
false
FStar.Modifies.fst
FStar.Modifies.region_liveness_insensitive_regions
val region_liveness_insensitive_regions (rs: Set.set HS.rid) : Lemma (region_liveness_insensitive_locs `loc_includes` (loc_regions true rs)) [SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_regions true rs))]
val region_liveness_insensitive_regions (rs: Set.set HS.rid) : Lemma (region_liveness_insensitive_locs `loc_includes` (loc_regions true rs)) [SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_regions true rs))]
let region_liveness_insensitive_regions = MG.loc_includes_region_liveness_insensitive_locs_loc_regions cls
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 66, "end_line": 290, "start_col": 0, "start_line": 289 }
(* 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
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
rs: FStar.Set.set FStar.Monotonic.HyperHeap.rid -> FStar.Pervasives.Lemma (ensures FStar.Modifies.loc_includes FStar.Modifies.region_liveness_insensitive_locs (FStar.Modifies.loc_regions true rs)) [ SMTPat (FStar.Modifies.loc_includes FStar.Modifies.region_liveness_insensitive_locs (FStar.Modifies.loc_regions true rs)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.loc_includes_region_liveness_insensitive_locs_loc_regions", "FStar.Modifies.aloc", "FStar.Modifies.cls" ]
[]
true
false
true
false
false
let region_liveness_insensitive_regions =
MG.loc_includes_region_liveness_insensitive_locs_loc_regions cls
false
FStar.Modifies.fst
FStar.Modifies.modifies_1_modifies
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)]
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 = 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) )
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 353, "start_col": 0, "start_line": 341 }
(* 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 _ _ -> ())
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
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))
false
FStar.Modifies.fst
FStar.Modifies.unused_in_does_not_contain_addr
val unused_in_does_not_contain_addr (h: HS.mem) (#a: Type) (#rel: Preorder.preorder a) (r: HS.mreference a rel) : Lemma (requires (r `HS.unused_in` h)) (ensures (h `does_not_contain_addr` (HS.frameOf r, HS.as_addr r)))
val unused_in_does_not_contain_addr (h: HS.mem) (#a: Type) (#rel: Preorder.preorder a) (r: HS.mreference a rel) : Lemma (requires (r `HS.unused_in` h)) (ensures (h `does_not_contain_addr` (HS.frameOf r, HS.as_addr r)))
let unused_in_does_not_contain_addr = MG.unused_in_does_not_contain_addr
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 72, "end_line": 422, "start_col": 0, "start_line": 422 }
(* 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
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
h: FStar.Monotonic.HyperStack.mem -> r: FStar.Monotonic.HyperStack.mreference a rel -> FStar.Pervasives.Lemma (requires FStar.Monotonic.HyperStack.unused_in r h) (ensures FStar.Modifies.does_not_contain_addr h (FStar.Monotonic.HyperStack.frameOf r, FStar.Monotonic.HyperStack.as_addr r))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.unused_in_does_not_contain_addr" ]
[]
true
false
true
false
false
let unused_in_does_not_contain_addr =
MG.unused_in_does_not_contain_addr
false
FStar.Modifies.fst
FStar.Modifies.mreference_live_buffer_unused_in_disjoint
val mreference_live_buffer_unused_in_disjoint (#t1: Type) (#pre: Preorder.preorder t1) (#t2: Type) (h: HS.mem) (b1: HS.mreference t1 pre) (b2: B.buffer t2) : Lemma (requires (HS.contains h b1 /\ B.unused_in b2 h)) (ensures (loc_disjoint (loc_freed_mreference b1) (loc_buffer b2))) [SMTPat (HS.contains h b1); SMTPat (B.unused_in b2 h)]
val mreference_live_buffer_unused_in_disjoint (#t1: Type) (#pre: Preorder.preorder t1) (#t2: Type) (h: HS.mem) (b1: HS.mreference t1 pre) (b2: B.buffer t2) : Lemma (requires (HS.contains h b1 /\ B.unused_in b2 h)) (ensures (loc_disjoint (loc_freed_mreference b1) (loc_buffer b2))) [SMTPat (HS.contains h b1); SMTPat (B.unused_in b2 h)]
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)
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 129, "end_line": 413, "start_col": 0, "start_line": 412 }
(* 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 _ _ -> ())
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
h: FStar.Monotonic.HyperStack.mem -> b1: FStar.Monotonic.HyperStack.mreference t1 pre -> b2: FStar.Buffer.buffer t2 -> FStar.Pervasives.Lemma (requires FStar.Monotonic.HyperStack.contains h b1 /\ FStar.Buffer.unused_in b2 h) (ensures FStar.Modifies.loc_disjoint (FStar.Modifies.loc_freed_mreference b1) (FStar.Modifies.loc_buffer b2)) [SMTPat (FStar.Monotonic.HyperStack.contains h b1); SMTPat (FStar.Buffer.unused_in b2 h)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mem", "FStar.Monotonic.HyperStack.mreference", "FStar.Buffer.buffer", "FStar.Modifies.loc_disjoint_includes", "FStar.Modifies.loc_freed_mreference", "FStar.Buffer.lseq", "FStar.Buffer.max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.content", "FStar.Modifies.loc_buffer", "Prims.unit" ]
[]
true
false
true
false
false
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)
false
FStar.Modifies.fst
FStar.Modifies.does_not_contain_addr_elim
val does_not_contain_addr_elim (#a: Type0) (#rel: Preorder.preorder a) (r: HS.mreference a rel) (m: HS.mem) (x: HS.rid * nat) : Lemma (requires ( m `does_not_contain_addr` x /\ HS.frameOf r == fst x /\ HS.as_addr r == snd x )) (ensures (~ (m `HS.contains` r)))
val does_not_contain_addr_elim (#a: Type0) (#rel: Preorder.preorder a) (r: HS.mreference a rel) (m: HS.mem) (x: HS.rid * nat) : Lemma (requires ( m `does_not_contain_addr` x /\ HS.frameOf r == fst x /\ HS.as_addr r == snd x )) (ensures (~ (m `HS.contains` r)))
let does_not_contain_addr_elim = MG.does_not_contain_addr_elim
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 428, "start_col": 0, "start_line": 428 }
(* 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 let free_does_not_contain_addr = MG.free_does_not_contain_addr
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
r: FStar.Monotonic.HyperStack.mreference a rel -> m: FStar.Monotonic.HyperStack.mem -> x: (FStar.Monotonic.HyperHeap.rid * Prims.nat) -> FStar.Pervasives.Lemma (requires FStar.Modifies.does_not_contain_addr m x /\ FStar.Monotonic.HyperStack.frameOf r == FStar.Pervasives.Native.fst x /\ FStar.Monotonic.HyperStack.as_addr r == FStar.Pervasives.Native.snd x) (ensures ~(FStar.Monotonic.HyperStack.contains m r))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.does_not_contain_addr_elim" ]
[]
true
false
true
false
false
let does_not_contain_addr_elim =
MG.does_not_contain_addr_elim
false
FStar.Modifies.fst
FStar.Modifies.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)]
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 = MG.free_does_not_contain_addr
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 426, "start_col": 0, "start_line": 426 }
(* 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
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.free_does_not_contain_addr" ]
[]
true
false
true
false
false
let free_does_not_contain_addr =
MG.free_does_not_contain_addr
false
FStar.Modifies.fst
FStar.Modifies.addr_unused_in_does_not_contain_addr
val addr_unused_in_does_not_contain_addr (h: HS.mem) (ra: HS.rid * nat) : Lemma (requires (HS.live_region h (fst ra) ==> snd ra `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (fst ra)))) (ensures (h `does_not_contain_addr` ra))
val addr_unused_in_does_not_contain_addr (h: HS.mem) (ra: HS.rid * nat) : Lemma (requires (HS.live_region h (fst ra) ==> snd ra `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (fst ra)))) (ensures (h `does_not_contain_addr` ra))
let addr_unused_in_does_not_contain_addr = MG.addr_unused_in_does_not_contain_addr
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 82, "end_line": 424, "start_col": 0, "start_line": 424 }
(* 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
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
h: FStar.Monotonic.HyperStack.mem -> ra: (FStar.Monotonic.HyperHeap.rid * Prims.nat) -> FStar.Pervasives.Lemma (requires FStar.Monotonic.HyperStack.live_region h (FStar.Pervasives.Native.fst ra) ==> FStar.Monotonic.Heap.addr_unused_in (FStar.Pervasives.Native.snd ra) (FStar.Map.sel (FStar.Monotonic.HyperStack.get_hmap h) (FStar.Pervasives.Native.fst ra))) (ensures FStar.Modifies.does_not_contain_addr h ra)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.addr_unused_in_does_not_contain_addr" ]
[]
true
false
true
false
false
let addr_unused_in_does_not_contain_addr =
MG.addr_unused_in_does_not_contain_addr
false
FStar.Modifies.fst
FStar.Modifies.modifies_only_live_addresses
val modifies_only_live_addresses (r: HS.rid) (a: Set.set nat) (l: loc) (h h' : HS.mem) : Lemma (requires ( modifies (loc_union (loc_addresses false r a) l) h h' /\ (forall x . Set.mem x a ==> h `does_not_contain_addr` (r, x)) )) (ensures (modifies l h h'))
val modifies_only_live_addresses (r: HS.rid) (a: Set.set nat) (l: loc) (h h' : HS.mem) : Lemma (requires ( modifies (loc_union (loc_addresses false r a) l) h h' /\ (forall x . Set.mem x a ==> h `does_not_contain_addr` (r, x)) )) (ensures (modifies l h h'))
let modifies_only_live_addresses = MG.modifies_only_live_addresses
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 66, "end_line": 430, "start_col": 0, "start_line": 430 }
(* 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 let free_does_not_contain_addr = MG.free_does_not_contain_addr let does_not_contain_addr_elim = MG.does_not_contain_addr_elim
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
r: FStar.Monotonic.HyperHeap.rid -> a: FStar.Set.set Prims.nat -> l: FStar.Modifies.loc -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.Modifies.modifies (FStar.Modifies.loc_union (FStar.Modifies.loc_addresses false r a) l ) h h' /\ (forall (x: Prims.nat). FStar.Set.mem x a ==> FStar.Modifies.does_not_contain_addr h (r, x)) ) (ensures FStar.Modifies.modifies l h h')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ModifiesGen.modifies_only_live_addresses", "FStar.Modifies.aloc", "FStar.Modifies.cls" ]
[]
true
false
true
false
false
let modifies_only_live_addresses =
MG.modifies_only_live_addresses
false
FStar.Modifies.fst
FStar.Modifies.modifies_2_modifies
val modifies_2_modifies (#a1 #a2: Type) (b1: B.buffer a1) (b2: B.buffer a2) (h1 h2: HS.mem) : Lemma (requires (B.modifies_2 b1 b2 h1 h2)) (ensures (modifies (loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2)) [SMTPat (B.modifies_2 b1 b2 h1 h2)]
val modifies_2_modifies (#a1 #a2: Type) (b1: B.buffer a1) (b2: B.buffer a2) (h1 h2: HS.mem) : Lemma (requires (B.modifies_2 b1 b2 h1 h2)) (ensures (modifies (loc_union (loc_buffer b1) (loc_buffer b2)) h1 h2)) [SMTPat (B.modifies_2 b1 b2 h1 h2)]
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) )
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 374, "start_col": 0, "start_line": 355 }
(* 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) )
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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" }
false
b1: FStar.Buffer.buffer a1 -> b2: FStar.Buffer.buffer a2 -> h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.Buffer.modifies_2 b1 b2 h1 h2) (ensures FStar.Modifies.modifies (FStar.Modifies.loc_union (FStar.Modifies.loc_buffer b1) (FStar.Modifies.loc_buffer b2)) h1 h2) [SMTPat (FStar.Buffer.modifies_2 b1 b2 h1 h2)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "FStar.ModifiesGen.modifies_intro", "FStar.Modifies.aloc", "FStar.Modifies.cls", "FStar.Modifies.loc_union", "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.Modifies.loc_disjoint_sym", "FStar.Modifies.loc_mreference", "FStar.Modifies.loc_disjoint_includes", "FStar.ModifiesGen.loc_disjoint_aloc_elim", "FStar.ModifiesGen.loc_of_aloc", "FStar.Buffer.lemma_reveal_modifies_2" ]
[]
false
false
true
false
false
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))
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.get
val get: Prims.unit -> rand store
val get: Prims.unit -> rand store
let get () : rand store = fun s -> Some s, fst s
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 36, "start_col": 0, "start_line": 36 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
_: Prims.unit -> FStar.DM4F.OTP.Random.rand FStar.DM4F.OTP.Random.store
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.OTP.Heap.id", "FStar.DM4F.OTP.Heap.tape", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "FStar.DM4F.OTP.Random.store", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.fst", "FStar.DM4F.OTP.Random.rand" ]
[]
false
false
false
true
false
let get () : rand store =
fun s -> Some s, fst s
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.return
val return (a: Type) (x: a) : rand a
val return (a: Type) (x: a) : rand a
let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 65, "end_line": 26, "start_col": 0, "start_line": 26 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
a: Type -> x: a -> FStar.DM4F.OTP.Random.rand a
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2", "FStar.DM4F.OTP.Heap.id", "FStar.DM4F.OTP.Heap.tape", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.DM4F.OTP.Random.rand" ]
[]
false
false
false
true
false
let return (a: Type) (x: a) : rand a =
fun (next, _) -> Some x, next
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.raise
val raise: a: Type -> Prims.unit -> rand a
val raise: a: Type -> Prims.unit -> rand a
let raise (a:Type) () : rand a = fun s -> None, fst s
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 42, "start_col": 0, "start_line": 42 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
a: Type -> _: Prims.unit -> FStar.DM4F.OTP.Random.rand a
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.OTP.Heap.id", "FStar.DM4F.OTP.Heap.tape", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.fst", "FStar.DM4F.OTP.Random.rand" ]
[]
false
false
false
true
false
let raise (a: Type) () : rand a =
fun s -> None, fst s
false
FStar.Modifies.fst
FStar.Modifies.modifies_3_modifies
val modifies_3_modifies (#a1 #a2 #a3: Type) (b1: B.buffer a1) (b2: B.buffer a2) (b3: B.buffer a3) (h1 h2: HS.mem) : Lemma (requires (B.modifies_3 b1 b2 b3 h1 h2)) (ensures (modifies (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2))
val modifies_3_modifies (#a1 #a2 #a3: Type) (b1: B.buffer a1) (b2: B.buffer a2) (b3: B.buffer a3) (h1 h2: HS.mem) : Lemma (requires (B.modifies_3 b1 b2 b3 h1 h2)) (ensures (modifies (loc_union (loc_buffer b1) (loc_union (loc_buffer b2) (loc_buffer b3))) h1 h2))
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) )
{ "file_name": "ulib/FStar.Modifies.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 402, "start_col": 0, "start_line": 378 }
(* 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"
{ "checked_file": "/", "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" }
[ { "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": 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 } ]
{ "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b1: FStar.Buffer.buffer a1 -> b2: FStar.Buffer.buffer a2 -> b3: FStar.Buffer.buffer a3 -> h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.Buffer.modifies_3 b1 b2 b3 h1 h2) (ensures FStar.Modifies.modifies (FStar.Modifies.loc_union (FStar.Modifies.loc_buffer b1) (FStar.Modifies.loc_union (FStar.Modifies.loc_buffer b2) (FStar.Modifies.loc_buffer b3))) h1 h2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "FStar.ModifiesGen.modifies_intro", "FStar.Modifies.aloc", "FStar.Modifies.cls", "FStar.Modifies.loc_union", "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.Modifies.loc_disjoint_sym", "FStar.Modifies.loc_mreference", "FStar.Modifies.loc_disjoint_includes", "FStar.ModifiesGen.loc_disjoint_aloc_elim", "FStar.ModifiesGen.loc_of_aloc", "FStar.Buffer.lemma_reveal_modifies_3" ]
[]
false
false
true
false
false
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))
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.bind
val bind (a b: Type) (c: rand a) (f: (a -> rand b)) : rand b
val bind (a b: Type) (c: rand a) (f: (a -> rand b)) : rand b
let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s)
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 33, "start_col": 0, "start_line": 28 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
a: Type -> b: Type -> c: FStar.DM4F.OTP.Random.rand a -> f: (_: a -> FStar.DM4F.OTP.Random.rand b) -> FStar.DM4F.OTP.Random.rand b
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.OTP.Random.rand", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.OTP.Heap.id", "FStar.DM4F.OTP.Heap.tape", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.snd" ]
[]
false
false
false
true
false
let bind (a b: Type) (c: rand a) (f: (a -> rand b)) : rand b =
fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s)
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.test_sample_none
val test_sample_none : v: FStar.DM4F.OTP.Heap.elem -> t: FStar.DM4F.OTP.Heap.tape {Prims.op_Negation (FStar.DM4F.OTP.Heap.incrementable (FStar.DM4F.OTP.Heap.to_id 9))} -> Prims.unit
let test_sample_none (v:elem) (t:tape { not (incrementable (to_id 9)) } ) = let f = reify (sample ()) in assert (f (to_id 9,t) == (None, to_id 9))
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 84, "start_col": 0, "start_line": 82 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem () let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
v: FStar.DM4F.OTP.Heap.elem -> t: FStar.DM4F.OTP.Heap.tape {Prims.op_Negation (FStar.DM4F.OTP.Heap.incrementable (FStar.DM4F.OTP.Heap.to_id 9))} -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.OTP.Heap.elem", "FStar.DM4F.OTP.Heap.tape", "Prims.b2t", "Prims.op_Negation", "FStar.DM4F.OTP.Heap.incrementable", "FStar.DM4F.OTP.Heap.to_id", "Prims._assert", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "FStar.DM4F.OTP.Heap.id", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.Some", "FStar.DM4F.OTP.Heap.index", "FStar.DM4F.OTP.Heap.incr", "Prims.bool", "FStar.DM4F.OTP.Random.sample", "Prims.unit" ]
[]
false
false
false
false
false
let test_sample_none (v: elem) (t: tape{not (incrementable (to_id 9))}) =
let f = reify (sample ()) in assert (f (to_id 9, t) == (None, to_id 9))
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.point
val point: #a:eqtype -> x:a -> y:option a -> nat
val point: #a:eqtype -> x:a -> y:option a -> nat
let point #a x = fun y -> if y = Some x then 1 else 0
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 128, "start_col": 0, "start_line": 128 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem () let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1)) let test_sample_none (v:elem) (t:tape { not (incrementable (to_id 9)) } ) = let f = reify (sample ()) in assert (f (to_id 9,t) == (None, to_id 9)) (** Bijection over tapes, the inverse function acts as a witness *) noeq type bijection = | Bijection: f:(tape -> tape) -> finv:(tape -> tape){forall (h:tape). equal (f (finv h)) h /\ equal (finv (f h)) h} -> bijection (** Inverse of a bijection *) let inverse (bij:bijection) : bijection = Bijection bij.finv bij.f (** Assume `sum` over `tape`. Definable as long as tape is finite *) assume val sum: f:(tape -> nat) -> nat (** Reordering terms in a sum doesn't change the result *) assume val sum_bijection: f:(tape -> nat) -> bij:bijection -> Lemma (sum f == sum (fun h -> f (bij.f h))) (** The sum of non-negative function is monotonic *) assume val sum_monotonic: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h <= g h)) (ensures (sum f <= sum g)) (** Corollary *) val sum_extensional: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h == g h)) (ensures (sum f == sum g)) let sum_extensional f g = sum_monotonic f g; sum_monotonic g f (** Unnormalized measure of a function `p` wrt the denotation of a probabilistic computation `f`. Assumes that the initial random tape is uniformly distributed When `p:a -> {0,1}` and `tape` is finite Pr[f : p] == 1/|tape| * sum_{h:tape} p (f h) == 1/|tape| * mass f p *) val mass: #a:Type -> f:(store -> M (a * id)) -> p:(a -> nat) -> nat let mass #a f p = sum (fun h -> let r,_ = f (to_id 0,h) in p r)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
x: a -> y: FStar.Pervasives.Native.option a -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.Pervasives.Native.option", "Prims.op_Equality", "FStar.Pervasives.Native.Some", "Prims.bool", "Prims.nat" ]
[]
false
false
false
false
false
let point #a x =
fun y -> if y = Some x then 1 else 0
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.sum_extensional
val sum_extensional: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h == g h)) (ensures (sum f == sum g))
val sum_extensional: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h == g h)) (ensures (sum f == sum g))
let sum_extensional f g = sum_monotonic f g; sum_monotonic g f
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 116, "start_col": 0, "start_line": 114 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem () let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1)) let test_sample_none (v:elem) (t:tape { not (incrementable (to_id 9)) } ) = let f = reify (sample ()) in assert (f (to_id 9,t) == (None, to_id 9)) (** Bijection over tapes, the inverse function acts as a witness *) noeq type bijection = | Bijection: f:(tape -> tape) -> finv:(tape -> tape){forall (h:tape). equal (f (finv h)) h /\ equal (finv (f h)) h} -> bijection (** Inverse of a bijection *) let inverse (bij:bijection) : bijection = Bijection bij.finv bij.f (** Assume `sum` over `tape`. Definable as long as tape is finite *) assume val sum: f:(tape -> nat) -> nat (** Reordering terms in a sum doesn't change the result *) assume val sum_bijection: f:(tape -> nat) -> bij:bijection -> Lemma (sum f == sum (fun h -> f (bij.f h))) (** The sum of non-negative function is monotonic *) assume val sum_monotonic: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h <= g h)) (ensures (sum f <= sum g)) (** Corollary *) val sum_extensional: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h == g h))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
f: (_: FStar.DM4F.OTP.Heap.tape -> Prims.nat) -> g: (_: FStar.DM4F.OTP.Heap.tape -> Prims.nat) -> FStar.Pervasives.Lemma (requires forall (h: FStar.DM4F.OTP.Heap.tape). f h == g h) (ensures FStar.DM4F.OTP.Random.sum f == FStar.DM4F.OTP.Random.sum g)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.OTP.Heap.tape", "Prims.nat", "FStar.DM4F.OTP.Random.sum_monotonic", "Prims.unit" ]
[]
true
false
true
false
false
let sum_extensional f g =
sum_monotonic f g; sum_monotonic g f
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.inverse
val inverse (bij: bijection) : bijection
val inverse (bij: bijection) : bijection
let inverse (bij:bijection) : bijection = Bijection bij.finv bij.f
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 95, "start_col": 0, "start_line": 94 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem () let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1)) let test_sample_none (v:elem) (t:tape { not (incrementable (to_id 9)) } ) = let f = reify (sample ()) in assert (f (to_id 9,t) == (None, to_id 9)) (** Bijection over tapes, the inverse function acts as a witness *) noeq type bijection = | Bijection: f:(tape -> tape) -> finv:(tape -> tape){forall (h:tape). equal (f (finv h)) h /\ equal (finv (f h)) h} -> bijection
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
bij: FStar.DM4F.OTP.Random.bijection -> FStar.DM4F.OTP.Random.bijection
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.OTP.Random.bijection", "FStar.DM4F.OTP.Random.Bijection", "FStar.DM4F.OTP.Random.__proj__Bijection__item__finv", "FStar.DM4F.OTP.Random.__proj__Bijection__item__f" ]
[]
false
false
false
true
false
let inverse (bij: bijection) : bijection =
Bijection bij.finv bij.f
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.mass
val mass: #a:Type -> f:(store -> M (a * id)) -> p:(a -> nat) -> nat
val mass: #a:Type -> f:(store -> M (a * id)) -> p:(a -> nat) -> nat
let mass #a f p = sum (fun h -> let r,_ = f (to_id 0,h) in p r)
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 63, "end_line": 125, "start_col": 0, "start_line": 125 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem () let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1)) let test_sample_none (v:elem) (t:tape { not (incrementable (to_id 9)) } ) = let f = reify (sample ()) in assert (f (to_id 9,t) == (None, to_id 9)) (** Bijection over tapes, the inverse function acts as a witness *) noeq type bijection = | Bijection: f:(tape -> tape) -> finv:(tape -> tape){forall (h:tape). equal (f (finv h)) h /\ equal (finv (f h)) h} -> bijection (** Inverse of a bijection *) let inverse (bij:bijection) : bijection = Bijection bij.finv bij.f (** Assume `sum` over `tape`. Definable as long as tape is finite *) assume val sum: f:(tape -> nat) -> nat (** Reordering terms in a sum doesn't change the result *) assume val sum_bijection: f:(tape -> nat) -> bij:bijection -> Lemma (sum f == sum (fun h -> f (bij.f h))) (** The sum of non-negative function is monotonic *) assume val sum_monotonic: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h <= g h)) (ensures (sum f <= sum g)) (** Corollary *) val sum_extensional: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h == g h)) (ensures (sum f == sum g)) let sum_extensional f g = sum_monotonic f g; sum_monotonic g f (** Unnormalized measure of a function `p` wrt the denotation of a probabilistic computation `f`. Assumes that the initial random tape is uniformly distributed When `p:a -> {0,1}` and `tape` is finite Pr[f : p] == 1/|tape| * sum_{h:tape} p (f h) == 1/|tape| * mass f p *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
f: (_: FStar.DM4F.OTP.Random.store -> Prims.M (a * FStar.DM4F.OTP.Heap.id)) -> p: (_: a -> Prims.nat) -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.OTP.Random.store", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.OTP.Heap.id", "Prims.nat", "FStar.DM4F.OTP.Random.sum", "FStar.DM4F.OTP.Heap.tape", "FStar.Pervasives.Native.Mktuple2", "FStar.DM4F.OTP.Heap.to_id" ]
[]
false
false
false
true
false
let mass #a f p =
sum (fun h -> let r, _ = f (to_id 0, h) in p r)
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.test_sample_some
val test_sample_some : v: FStar.DM4F.OTP.Heap.elem -> t: FStar.DM4F.OTP.Heap.tape { FStar.DM4F.OTP.Heap.sel t (FStar.DM4F.OTP.Heap.to_id 0) == v /\ FStar.DM4F.OTP.Heap.incrementable (FStar.DM4F.OTP.Heap.to_id 0) /\ FStar.DM4F.OTP.Heap.incr (FStar.DM4F.OTP.Heap.to_id 0) == FStar.DM4F.OTP.Heap.to_id 1 } -> Prims.unit
let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1))
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 79, "start_col": 0, "start_line": 73 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
v: FStar.DM4F.OTP.Heap.elem -> t: FStar.DM4F.OTP.Heap.tape { FStar.DM4F.OTP.Heap.sel t (FStar.DM4F.OTP.Heap.to_id 0) == v /\ FStar.DM4F.OTP.Heap.incrementable (FStar.DM4F.OTP.Heap.to_id 0) /\ FStar.DM4F.OTP.Heap.incr (FStar.DM4F.OTP.Heap.to_id 0) == FStar.DM4F.OTP.Heap.to_id 1 } -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.OTP.Heap.elem", "FStar.DM4F.OTP.Heap.tape", "Prims.l_and", "Prims.eq2", "FStar.DM4F.OTP.Heap.sel", "FStar.DM4F.OTP.Heap.to_id", "Prims.b2t", "FStar.DM4F.OTP.Heap.incrementable", "FStar.DM4F.OTP.Heap.id", "FStar.DM4F.OTP.Heap.incr", "Prims._assert", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.Some", "FStar.DM4F.OTP.Heap.index", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.DM4F.OTP.Random.sample", "Prims.unit" ]
[]
false
false
false
false
false
let test_sample_some (v: elem) (t: tape{sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1}) =
let f = reify (sample ()) in assert (f (to_id 0, t) == (Some v, to_id 1))
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.pr_leq
val pr_leq: #a:Type -> #b:Type -> c1:(store -> M (a * id)) -> c2:(store -> M (b * id)) -> p1:(a -> nat) -> p2:(b -> nat) -> bij:bijection -> Lemma (requires (forall t. let r1,_ = c1 (to_id 0,t) in let r2,_ = c2 (to_id 0,bij.f t) in p1 r1 <= p2 r2)) (ensures (mass c1 p1 <= mass c2 p2))
val pr_leq: #a:Type -> #b:Type -> c1:(store -> M (a * id)) -> c2:(store -> M (b * id)) -> p1:(a -> nat) -> p2:(b -> nat) -> bij:bijection -> Lemma (requires (forall t. let r1,_ = c1 (to_id 0,t) in let r2,_ = c2 (to_id 0,bij.f t) in p1 r1 <= p2 r2)) (ensures (mass c1 p1 <= mass c2 p2))
let pr_leq #a #b c1 c2 p1 p2 bij = let bij' = inverse bij in let f1 = (fun h -> let r1,_ = c1 (to_id 0,h) in p1 r1) in let f2 = (fun h -> let r2,_ = c2 (to_id 0,h) in p2 r2) in sum_monotonic f1 (fun h -> let r2,_ = c2 (to_id 0,bij.f h) in p2 r2); sum_bijection (fun h -> let r2,_ = c2 (to_id 0,bij.f h) in p2 r2) bij'; sum_extensional (fun h -> let r2,_ = c2 (to_id 0,bij.f (bij'.f h)) in p2 r2) f2
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 81, "end_line": 153, "start_col": 0, "start_line": 147 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem () let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1)) let test_sample_none (v:elem) (t:tape { not (incrementable (to_id 9)) } ) = let f = reify (sample ()) in assert (f (to_id 9,t) == (None, to_id 9)) (** Bijection over tapes, the inverse function acts as a witness *) noeq type bijection = | Bijection: f:(tape -> tape) -> finv:(tape -> tape){forall (h:tape). equal (f (finv h)) h /\ equal (finv (f h)) h} -> bijection (** Inverse of a bijection *) let inverse (bij:bijection) : bijection = Bijection bij.finv bij.f (** Assume `sum` over `tape`. Definable as long as tape is finite *) assume val sum: f:(tape -> nat) -> nat (** Reordering terms in a sum doesn't change the result *) assume val sum_bijection: f:(tape -> nat) -> bij:bijection -> Lemma (sum f == sum (fun h -> f (bij.f h))) (** The sum of non-negative function is monotonic *) assume val sum_monotonic: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h <= g h)) (ensures (sum f <= sum g)) (** Corollary *) val sum_extensional: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h == g h)) (ensures (sum f == sum g)) let sum_extensional f g = sum_monotonic f g; sum_monotonic g f (** Unnormalized measure of a function `p` wrt the denotation of a probabilistic computation `f`. Assumes that the initial random tape is uniformly distributed When `p:a -> {0,1}` and `tape` is finite Pr[f : p] == 1/|tape| * sum_{h:tape} p (f h) == 1/|tape| * mass f p *) val mass: #a:Type -> f:(store -> M (a * id)) -> p:(a -> nat) -> nat let mass #a f p = sum (fun h -> let r,_ = f (to_id 0,h) in p r) val point: #a:eqtype -> x:a -> y:option a -> nat let point #a x = fun y -> if y = Some x then 1 else 0 (** If there exists a bijection over tapes such that `p1` evaluated on the result of `c1` is less than or equal to `p2` evaluated on the result of `c2`, then the measure of `p1` wrt `c1` is less than or equal to the measure of `p2` wrt `c2` *) val pr_leq: #a:Type -> #b:Type -> c1:(store -> M (a * id)) -> c2:(store -> M (b * id)) -> p1:(a -> nat) -> p2:(b -> nat) -> bij:bijection -> Lemma (requires (forall t. let r1,_ = c1 (to_id 0,t) in let r2,_ = c2 (to_id 0,bij.f t) in p1 r1 <= p2 r2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
c1: (_: FStar.DM4F.OTP.Random.store -> Prims.M (a * FStar.DM4F.OTP.Heap.id)) -> c2: (_: FStar.DM4F.OTP.Random.store -> Prims.M (b * FStar.DM4F.OTP.Heap.id)) -> p1: (_: a -> Prims.nat) -> p2: (_: b -> Prims.nat) -> bij: FStar.DM4F.OTP.Random.bijection -> FStar.Pervasives.Lemma (requires forall (t: FStar.DM4F.OTP.Heap.tape). let _ = c1 (FStar.DM4F.OTP.Heap.to_id 0, t) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r1 _ = _ in let _ = c2 (FStar.DM4F.OTP.Heap.to_id 0, Bijection?.f bij t) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r2 _ = _ in p1 r1 <= p2 r2) <: Type0) <: Type0) (ensures FStar.DM4F.OTP.Random.mass c1 p1 <= FStar.DM4F.OTP.Random.mass c2 p2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.OTP.Random.store", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.OTP.Heap.id", "Prims.nat", "FStar.DM4F.OTP.Random.bijection", "FStar.DM4F.OTP.Random.sum_extensional", "FStar.DM4F.OTP.Heap.tape", "FStar.Pervasives.Native.Mktuple2", "FStar.DM4F.OTP.Heap.to_id", "FStar.DM4F.OTP.Random.__proj__Bijection__item__f", "Prims.unit", "FStar.DM4F.OTP.Random.sum_bijection", "FStar.DM4F.OTP.Random.sum_monotonic", "FStar.DM4F.OTP.Random.inverse" ]
[]
false
false
true
false
false
let pr_leq #a #b c1 c2 p1 p2 bij =
let bij' = inverse bij in let f1 = (fun h -> let r1, _ = c1 (to_id 0, h) in p1 r1) in let f2 = (fun h -> let r2, _ = c2 (to_id 0, h) in p2 r2) in sum_monotonic f1 (fun h -> let r2, _ = c2 (to_id 0, bij.f h) in p2 r2); sum_bijection (fun h -> let r2, _ = c2 (to_id 0, bij.f h) in p2 r2) bij'; sum_extensional (fun h -> let r2, _ = c2 (to_id 0, bij.f (bij'.f h)) in p2 r2) f2
false
FStar.DM4F.OTP.Random.fst
FStar.DM4F.OTP.Random.pr_eq
val pr_eq: #a:Type -> #b:Type -> c1:(store -> M (a * id)) -> c2:(store -> M (b * id)) -> p1:(a -> nat) -> p2:(b -> nat) -> bij:bijection -> Lemma (requires (forall h. let r1,_ = c1 (to_id 0, h) in let r2,_ = c2 (to_id 0, bij.f h) in p1 r1 == p2 r2)) (ensures (mass c1 p1 == mass c2 p2))
val pr_eq: #a:Type -> #b:Type -> c1:(store -> M (a * id)) -> c2:(store -> M (b * id)) -> p1:(a -> nat) -> p2:(b -> nat) -> bij:bijection -> Lemma (requires (forall h. let r1,_ = c1 (to_id 0, h) in let r2,_ = c2 (to_id 0, bij.f h) in p1 r1 == p2 r2)) (ensures (mass c1 p1 == mass c2 p2))
let pr_eq #a #b c1 c2 p1 p2 bij = pr_leq c1 c2 p1 p2 bij; pr_leq c2 c1 p2 p1 (inverse bij)
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 170, "start_col": 0, "start_line": 168 }
(* 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.DM4F.OTP.Random open FStar.DM4F.OTP.Heap (* for some reason this `unfold` makes everything 25% faster *) unfold type store = (id * tape) (** Read-only tape with a pointer to the next unread position *) type rand (a:Type) = (id * tape) -> M (option a * id) let return (a:Type) (x:a) : rand a = fun (next,_) -> Some x, next let bind (a b:Type) (c:rand a) (f:a -> rand b) : rand b = fun s -> let r, next = c s in match r with | None -> None, next | Some x -> f x (next, snd s) (** Get store *) let get () : rand store = fun s -> Some s, fst s (** Update tape pointer *) let put i : rand unit = fun _ -> Some (), i (** Raise exception *) let raise (a:Type) () : rand a = fun s -> None, fst s total reifiable reflectable new_effect { RAND: a:Type -> Effect with repr = rand ; bind = bind ; return = return ; get = get ; put = put ; raise = raise } effect Rand (a:Type) = RAND a (fun initial_tape post -> forall (x:option a * id). post x) (** If not past the end of the tape, read a value and advance pointer *) reifiable val sample: unit -> RAND elem (fun (next,t) p -> if incrementable next then p (Some (index t next), incr next) else p (None, next)) let sample () = let next, t = RAND?.get () in if incrementable next then begin RAND?.put (incr next); index t next end else RAND?.raise elem () let test_sample_some (v:elem) (t:tape{ sel t (to_id 0) == v /\ incrementable (to_id 0) /\ incr (to_id 0) == to_id 1 }) = let f = reify (sample()) in assert (f (to_id 0,t) == (Some v, to_id 1)) let test_sample_none (v:elem) (t:tape { not (incrementable (to_id 9)) } ) = let f = reify (sample ()) in assert (f (to_id 9,t) == (None, to_id 9)) (** Bijection over tapes, the inverse function acts as a witness *) noeq type bijection = | Bijection: f:(tape -> tape) -> finv:(tape -> tape){forall (h:tape). equal (f (finv h)) h /\ equal (finv (f h)) h} -> bijection (** Inverse of a bijection *) let inverse (bij:bijection) : bijection = Bijection bij.finv bij.f (** Assume `sum` over `tape`. Definable as long as tape is finite *) assume val sum: f:(tape -> nat) -> nat (** Reordering terms in a sum doesn't change the result *) assume val sum_bijection: f:(tape -> nat) -> bij:bijection -> Lemma (sum f == sum (fun h -> f (bij.f h))) (** The sum of non-negative function is monotonic *) assume val sum_monotonic: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h <= g h)) (ensures (sum f <= sum g)) (** Corollary *) val sum_extensional: f:(tape -> nat) -> g:(tape -> nat) -> Lemma (requires (forall h. f h == g h)) (ensures (sum f == sum g)) let sum_extensional f g = sum_monotonic f g; sum_monotonic g f (** Unnormalized measure of a function `p` wrt the denotation of a probabilistic computation `f`. Assumes that the initial random tape is uniformly distributed When `p:a -> {0,1}` and `tape` is finite Pr[f : p] == 1/|tape| * sum_{h:tape} p (f h) == 1/|tape| * mass f p *) val mass: #a:Type -> f:(store -> M (a * id)) -> p:(a -> nat) -> nat let mass #a f p = sum (fun h -> let r,_ = f (to_id 0,h) in p r) val point: #a:eqtype -> x:a -> y:option a -> nat let point #a x = fun y -> if y = Some x then 1 else 0 (** If there exists a bijection over tapes such that `p1` evaluated on the result of `c1` is less than or equal to `p2` evaluated on the result of `c2`, then the measure of `p1` wrt `c1` is less than or equal to the measure of `p2` wrt `c2` *) val pr_leq: #a:Type -> #b:Type -> c1:(store -> M (a * id)) -> c2:(store -> M (b * id)) -> p1:(a -> nat) -> p2:(b -> nat) -> bij:bijection -> Lemma (requires (forall t. let r1,_ = c1 (to_id 0,t) in let r2,_ = c2 (to_id 0,bij.f t) in p1 r1 <= p2 r2)) (ensures (mass c1 p1 <= mass c2 p2)) let pr_leq #a #b c1 c2 p1 p2 bij = let bij' = inverse bij in let f1 = (fun h -> let r1,_ = c1 (to_id 0,h) in p1 r1) in let f2 = (fun h -> let r2,_ = c2 (to_id 0,h) in p2 r2) in sum_monotonic f1 (fun h -> let r2,_ = c2 (to_id 0,bij.f h) in p2 r2); sum_bijection (fun h -> let r2,_ = c2 (to_id 0,bij.f h) in p2 r2) bij'; sum_extensional (fun h -> let r2,_ = c2 (to_id 0,bij.f (bij'.f h)) in p2 r2) f2 (** Corollary *) val pr_eq: #a:Type -> #b:Type -> c1:(store -> M (a * id)) -> c2:(store -> M (b * id)) -> p1:(a -> nat) -> p2:(b -> nat) -> bij:bijection -> Lemma (requires (forall h. let r1,_ = c1 (to_id 0, h) in let r2,_ = c2 (to_id 0, bij.f h) in p1 r1 == p2 r2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.OTP.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.OTP.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "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 } ]
{ "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" }
false
c1: (_: FStar.DM4F.OTP.Random.store -> Prims.M (a * FStar.DM4F.OTP.Heap.id)) -> c2: (_: FStar.DM4F.OTP.Random.store -> Prims.M (b * FStar.DM4F.OTP.Heap.id)) -> p1: (_: a -> Prims.nat) -> p2: (_: b -> Prims.nat) -> bij: FStar.DM4F.OTP.Random.bijection -> FStar.Pervasives.Lemma (requires forall (h: FStar.DM4F.OTP.Heap.tape). let _ = c1 (FStar.DM4F.OTP.Heap.to_id 0, h) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r1 _ = _ in let _ = c2 (FStar.DM4F.OTP.Heap.to_id 0, Bijection?.f bij h) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r2 _ = _ in p1 r1 == p2 r2) <: Type0) <: Type0) (ensures FStar.DM4F.OTP.Random.mass c1 p1 == FStar.DM4F.OTP.Random.mass c2 p2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.OTP.Random.store", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.OTP.Heap.id", "Prims.nat", "FStar.DM4F.OTP.Random.bijection", "FStar.DM4F.OTP.Random.pr_leq", "FStar.DM4F.OTP.Random.inverse", "Prims.unit" ]
[]
true
false
true
false
false
let pr_eq #a #b c1 c2 p1 p2 bij =
pr_leq c1 c2 p1 p2 bij; pr_leq c2 c1 p2 p1 (inverse bij)
false
Spec.Frodo.Lemmas.fst
Spec.Frodo.Lemmas.lemma_frodo_sample2
val lemma_frodo_sample2: sign:uint16{v sign <= 1} -> e:uint16 -> Lemma (((lognot sign +. u16 1) ^. e) +. sign == u16 ((Math.Lib.powx (-1) (v sign) * v e) % modulus U16))
val lemma_frodo_sample2: sign:uint16{v sign <= 1} -> e:uint16 -> Lemma (((lognot sign +. u16 1) ^. e) +. sign == u16 ((Math.Lib.powx (-1) (v sign) * v e) % modulus U16))
let lemma_frodo_sample2 sign e = calc (==) { v ((lognot sign +. u16 1) ^. e); (==) { logxor_spec (lognot sign +. u16 1) e } logxor_v #U16 (v (lognot sign +. u16 1)) (v e); (==) { lognot_plus_one sign } logxor_v #U16 ((modulus U16 - v sign) % modulus U16) (v e); (==) { UInt.logxor_commutative #16 ((modulus U16 - v sign) % modulus U16) (v e) } logxor_v #U16 (v e) ((modulus U16 - v sign) % modulus U16); }; if v sign = 0 then begin calc (==) { logxor_v #U16 (v e) ((modulus U16 - v sign) % modulus U16); (==) { Math.Lemmas.multiple_modulo_lemma 1 (modulus U16) } logxor_v #U16 (v e) 0; (==) { UInt.logxor_lemma_1 #16 (v e) } v e; }; assert (v (((lognot sign +. u16 1) ^. e) +. sign) == v e); assert_norm (Math.Lib.powx (-1) 0 = 1); Math.Lemmas.small_mod (v e) (modulus U16) end else begin calc (==) { logxor_v #U16 (v e) ((modulus U16 - v sign) % modulus U16); (==) { Math.Lemmas.small_mod (modulus U16 - v sign) (modulus U16) } logxor_v #U16 (v e) (UInt.ones 16); (==) { UInt.logxor_lemma_2 #16 (v e) } lognot_v #U16 (v e); (==) { UInt.lemma_lognot_value_mod #16 (v e) } modulus U16 - v e - 1; }; assert (v (((lognot sign +. u16 1) ^. e) +. sign) == (modulus U16 - v e) % modulus U16); assert_norm (Math.Lib.powx (-1) 1 = -1) end
{ "file_name": "specs/frodo/Spec.Frodo.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 100, "start_col": 0, "start_line": 65 }
module Spec.Frodo.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_mask_cast: mask:uint16{v mask = 0 \/ v mask = v (ones U16 SEC)} -> Lemma ((v mask = 0 ==> v (to_u8 mask) = 0) /\ (v mask = v (ones U16 SEC) ==> v (to_u8 mask) = v (ones U8 SEC))) let lemma_mask_cast mask = () // To avoid integral promotion, a cast to uint_16 is needed // https://en.cppreference.com/w/cpp/language/operator_arithmetic val lemma_frodo_sample: a:uint16{v a < pow2 15} -> b:uint16{v b < pow2 15} -> Lemma (let c0 = if v a > v b then 1 else 0 in let c1 = to_u16 (to_u32 (b -. a)) >>. 15ul in v c1 == c0) let lemma_frodo_sample a b = let c = to_u16 (to_u32 (b -. a)) in assert (v c < modulus U16); Math.Lemmas.lemma_div_lt (uint_v c) 16 15; let c1 = c >>. 15ul in assert (v c1 = v c / pow2 15); Math.Lemmas.pow2_minus 16 15; assert (v c1 = 0 \/ v c1 = 1) val modulo_pow2_u16: a:uint16 -> b:size_nat{b < 16} -> Lemma (v a % pow2 b == v (a &. ((u16 1 <<. size b) -. u16 1))) let modulo_pow2_u16 a b = Math.Lemmas.pow2_lt_compat 16 b; mod_mask_lemma #U16 a (size b); assert (v (mod_mask #U16 #SEC (size b)) == v ((u16 1 <<. size b) -. u16 1)) val modulo_pow2_u64: a:uint64 -> b:size_nat{b < 64} -> Lemma (v a % pow2 b == v (a &. ((u64 1 <<. size b) -. u64 1))) let modulo_pow2_u64 a b = Math.Lemmas.pow2_lt_compat 64 b; mod_mask_lemma #U64 a (size b); assert (v (mod_mask #U64 #SEC (size b)) == v ((u64 1 <<. size b) -. u64 1)) val lognot_plus_one: e:uint16 -> Lemma (v (lognot e) == modulus U16 - v e - 1) let lognot_plus_one e = lognot_spec e; assert (v (lognot e) == UInt.lognot #16 (v e)); UInt.lemma_lognot_value_mod #16 (v e); assert (v (lognot e) == pow2 16 - v e - 1) val lemma_frodo_sample2: sign:uint16{v sign <= 1} -> e:uint16 -> Lemma (((lognot sign +. u16 1) ^. e) +. sign == u16 ((Math.Lib.powx (-1) (v sign) * v e) % modulus U16))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "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 } ]
{ "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" }
false
sign: Lib.IntTypes.uint16{Lib.IntTypes.v sign <= 1} -> e: Lib.IntTypes.uint16 -> FStar.Pervasives.Lemma (ensures (Lib.IntTypes.lognot sign +. Lib.IntTypes.u16 1 ^. e) +. sign == Lib.IntTypes.u16 (FStar.Math.Lib.powx (- 1) (Lib.IntTypes.v sign) * Lib.IntTypes.v e % Lib.IntTypes.modulus Lib.IntTypes.U16))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Lib.IntTypes.uint16", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Prims.op_Equality", "Prims.int", "FStar.Math.Lemmas.small_mod", "Lib.IntTypes.modulus", "Prims.unit", "FStar.Pervasives.assert_norm", "FStar.Math.Lib.powx", "Prims.op_Minus", "Prims._assert", "Prims.eq2", "Lib.IntTypes.range_t", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.op_Hat_Dot", "Lib.IntTypes.lognot", "Lib.IntTypes.u16", "FStar.Calc.calc_finish", "Lib.IntTypes.logxor_v", "Prims.op_Modulus", "Prims.op_Subtraction", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.multiple_modulo_lemma", "Prims.squash", "FStar.UInt.logxor_lemma_1", "Prims.bool", "Lib.IntTypes.lognot_v", "FStar.UInt.ones", "FStar.UInt.logxor_lemma_2", "FStar.UInt.lemma_lognot_value_mod", "Lib.IntTypes.logxor_spec", "Spec.Frodo.Lemmas.lognot_plus_one", "FStar.UInt.logxor_commutative" ]
[]
false
false
true
false
false
let lemma_frodo_sample2 sign e =
calc ( == ) { v ((lognot sign +. u16 1) ^. e); ( == ) { logxor_spec (lognot sign +. u16 1) e } logxor_v #U16 (v (lognot sign +. u16 1)) (v e); ( == ) { lognot_plus_one sign } logxor_v #U16 ((modulus U16 - v sign) % modulus U16) (v e); ( == ) { UInt.logxor_commutative #16 ((modulus U16 - v sign) % modulus U16) (v e) } logxor_v #U16 (v e) ((modulus U16 - v sign) % modulus U16); }; if v sign = 0 then (calc ( == ) { logxor_v #U16 (v e) ((modulus U16 - v sign) % modulus U16); ( == ) { Math.Lemmas.multiple_modulo_lemma 1 (modulus U16) } logxor_v #U16 (v e) 0; ( == ) { UInt.logxor_lemma_1 #16 (v e) } v e; }; assert (v (((lognot sign +. u16 1) ^. e) +. sign) == v e); assert_norm (Math.Lib.powx (- 1) 0 = 1); Math.Lemmas.small_mod (v e) (modulus U16)) else (calc ( == ) { logxor_v #U16 (v e) ((modulus U16 - v sign) % modulus U16); ( == ) { Math.Lemmas.small_mod (modulus U16 - v sign) (modulus U16) } logxor_v #U16 (v e) (UInt.ones 16); ( == ) { UInt.logxor_lemma_2 #16 (v e) } lognot_v #U16 (v e); ( == ) { UInt.lemma_lognot_value_mod #16 (v e) } modulus U16 - v e - 1; }; assert (v (((lognot sign +. u16 1) ^. e) +. sign) == (modulus U16 - v e) % modulus U16); assert_norm (Math.Lib.powx (- 1) 1 = - 1))
false
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_load_mem_get128
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))]
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 = MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 37, "start_col": 0, "start_line": 34 }
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; ()
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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))]
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
false
let lemma_load_mem_get128 h ptr =
MS.equiv_load_mem128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
false
Hacl.Spec.Bignum.MontArithmetic.fsti
Hacl.Spec.Bignum.MontArithmetic.bn_mont_nat
val bn_mont_nat : k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Type0
let bn_mont_nat (#t:limb_t) (k:bn_mont_ctx t) = x:lbignum t k.len{bn_v x < bn_v k.n}
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 37, "start_col": 0, "start_line": 36 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
let bn_mont_nat (#t: limb_t) (k: bn_mont_ctx t) =
x: lbignum t k.len {bn_v x < bn_v k.n}
false
Hacl.Spec.Bignum.MontArithmetic.fsti
Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_pre
val bn_mont_ctx_pre : n: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.logical
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
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 17, "start_col": 0, "start_line": 16 }
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"
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.logical
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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
false
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_to_of
val lemma_to_of (s:machine_state) : Lemma (ensures state_to_S (state_of_S s) == {s with Ms.ms_trace = []})
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 = 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; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 80, "start_col": 0, "start_line": 73 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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) [])
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
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; ()
false
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_valid_mem_addr128
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))]
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 = MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 27, "start_col": 0, "start_line": 24 }
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; ()
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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))]
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
false
let lemma_valid_mem_addr128 h ptr =
MS.bytes_valid128 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
false
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_valid_mem_addr64
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))]
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 = MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 22, "start_col": 0, "start_line": 19 }
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 () = ()
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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))]
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
false
let lemma_valid_mem_addr64 h ptr =
MS.bytes_valid64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
false
Hacl.Spec.Bignum.MontArithmetic.fsti
Hacl.Spec.Bignum.MontArithmetic.bn_field_exp_st
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
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))
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 101, "end_line": 115, "start_col": 0, "start_line": 108 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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))
false
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_load_mem_get64
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))]
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 = MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 32, "start_col": 0, "start_line": 29 }
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; ()
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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))]
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
false
let lemma_load_mem_get64 h ptr =
MS.equiv_load_mem64 ptr (get_vale_heap h); MS.lemma_heap_get_heap h; ()
false
Hacl.Spec.Bignum.MontArithmetic.fsti
Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv
val bn_mont_ctx_inv : k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
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
{ "file_name": "code/bignum/Hacl.Spec.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 33, "start_col": 0, "start_line": 29 }
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 }
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_load_buffer_read128
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)]
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 = lemma_load_mem128 b i h
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 49, "start_col": 0, "start_line": 48 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Arch.HeapImpl.vale_heap", "Vale.X64.Memory.buffer128", "Prims.int", "Vale.X64.Memory.lemma_load_mem128", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_load_buffer_read128 h b i =
lemma_load_mem128 b i h
false
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_to_eval_operand
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)]
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 = allow_inversion tmaddr; allow_inversion maddr
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 55, "start_col": 0, "start_line": 53 }
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"
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
false
let lemma_to_eval_operand s o =
allow_inversion tmaddr; allow_inversion maddr
false
Hacl.Test.ECDSA.fst
Hacl.Test.ECDSA.test_siggen_256
val test_siggen_256 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True)
val test_siggen_256 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True)
let test_siggen_256 (vec:siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha2 rs msg_len msg d k in if flag then begin let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then begin let result = ecdsa_verif_p256_sha2 msg_len msg qxy r s in if not result then begin LowStar.Printf.(printf "FAIL: verification\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end; pop_frame() end
{ "file_name": "code/tests/Hacl.Test.ECDSA.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 329, "start_col": 0, "start_line": 267 }
module Hacl.Test.ECDSA open FStar.HyperStack.ST open Test.Lowstarize open Lib.IntTypes open Hacl.P256 open Spec.ECDSA.Test.Vectors module L = Test.Lowstarize module B = LowStar.Buffer #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" noextract let sigver_vectors256_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_256 noextract let sigver_vectors384_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_384 noextract let sigver_vectors512_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_512 noextract let siggen_vectors256_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_256 noextract let siggen_vectors384_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_384 noextract let siggen_vectors512_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_512 %splice[sigver_vectors256_low] (lowstarize_toplevel "sigver_vectors256_tmp" "sigver_vectors256_low") %splice[sigver_vectors384_low] (lowstarize_toplevel "sigver_vectors384_tmp" "sigver_vectors384_low") %splice[sigver_vectors512_low] (lowstarize_toplevel "sigver_vectors512_tmp" "sigver_vectors512_low") %splice[siggen_vectors256_low] (lowstarize_toplevel "siggen_vectors256_tmp" "siggen_vectors256_low") %splice[siggen_vectors384_low] (lowstarize_toplevel "siggen_vectors384_tmp" "siggen_vectors384_low") %splice[siggen_vectors512_low] (lowstarize_toplevel "siggen_vectors512_tmp" "siggen_vectors512_low") // Cheap alternative to friend Lib.IntTypes needed because Test.Lowstarize uses UInt8.t assume val declassify_uint8: squash (uint8 == UInt8.t) let vec8 = L.lbuffer UInt8.t let sigver_vector = vec8 & vec8 & vec8 & vec8 & vec8 & bool let siggen_vector = vec8 & vec8 & vec8 & vec8 & vec8 & vec8 & vec8 // This could replace TestLib.compare_and_print val compare_and_print: b1:B.buffer UInt8.t -> b2:B.buffer UInt8.t -> len:UInt32.t -> Stack bool (requires fun h0 -> B.live h0 b1 /\ B.live h0 b2 /\ B.length b1 == v len /\ B.length b2 == v len) (ensures fun h0 _ h1 -> B.modifies B.loc_none h0 h1) let compare_and_print b1 b2 len = push_frame(); LowStar.Printf.(printf "Expected: %xuy\n" len b1 done); LowStar.Printf.(printf "Computed: %xuy\n" len b2 done); let b = Lib.ByteBuffer.lbytes_eq #len b1 b2 in if b then LowStar.Printf.(printf "PASS\n" done) else LowStar.Printf.(printf "FAIL\n" done); pop_frame(); b let test_sigver256 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha2 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end let test_sigver384 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha384 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end let test_sigver512 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha512 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end #push-options "--fuel 1 --ifuel 1 --z3rlimit 200" val check_bound: b:Lib.Buffer.lbuffer uint8 32ul -> Stack bool (requires fun h -> Lib.Buffer.live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == ( (Lib.ByteSequence.nat_from_bytes_be (Lib.Buffer.as_seq h0 b) > 0) && (Lib.ByteSequence.nat_from_bytes_be (Lib.Buffer.as_seq h0 b) < Spec.P256.order))) let check_bound b = let open FStar.Mul in let open Lib.ByteSequence in let open Spec.P256 in [@inline_let] let q1 = normalize_term (order % pow2 64) in [@inline_let] let q2 = normalize_term ((order / pow2 64) % pow2 64) in [@inline_let] let q3 = normalize_term ((order / pow2 128) % pow2 64) in [@inline_let] let q4 = normalize_term (((order / pow2 128) / pow2 64) % pow2 64) in assert_norm (pow2 128 * pow2 64 == pow2 192); assert (order == q1 + pow2 64 * q2 + pow2 128 * q3 + pow2 192 * q4); let zero = mk_int #U64 #PUB 0 in let q1 = mk_int #U64 #PUB q1 in let q2 = mk_int #U64 #PUB q2 in let q3 = mk_int #U64 #PUB q3 in let q4 = mk_int #U64 #PUB q4 in let h0 = get () in let x1 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 0ul 8ul) in let x2 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 8ul 8ul) in let x3 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 16ul 8ul) in let x4 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 24ul 8ul) in nat_from_intseq_be_slice_lemma (Lib.Buffer.as_seq h0 b) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 0 8); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 8 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 8 16); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 16 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 16 24); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 24 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 24 32); let x1 = Lib.RawIntTypes.u64_to_UInt64 x1 in let x2 = Lib.RawIntTypes.u64_to_UInt64 x2 in let x3 = Lib.RawIntTypes.u64_to_UInt64 x3 in let x4 = Lib.RawIntTypes.u64_to_UInt64 x4 in let r = x1 <. q4 || (x1 =. q4 && (x2 <. q3 || (x2 =. q3 && (x3 <. q2 || (x3 =. q2 && x4 <. q1))))) in let r1 = x1 = zero && x2 = zero && x3 = zero && x4 = zero in r && not r1 #push-options " --ifuel 1 --fuel 1"
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.P256.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "LowStar.Printf.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.P256.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "C.String.fsti.checked", "C.Loops.fst.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.ECDSA.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Test.Lowstarize", "short_module": "L" }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": 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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
vec: Hacl.Test.ECDSA.siggen_vector -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Test.ECDSA.siggen_vector", "FStar.UInt32.t", "LowStar.Buffer.buffer", "FStar.UInt8.t", "Prims.l_and", "Prims.eq2", "LowStar.Monotonic.Buffer.len", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.recallable", "Prims.op_Negation", "Prims.op_AmpAmp", "Prims.op_Equality", "FStar.UInt32.__uint_to_t", "C.exit", "FStar.Int32.__int_to_t", "Prims.unit", "Prims.bool", "FStar.HyperStack.ST.pop_frame", "LowStar.Printf.printf", "LowStar.Printf.done", "Hacl.P256.ecdsa_verif_p256_sha2", "Hacl.Test.ECDSA.compare_and_print", "LowStar.Buffer.sub", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.mbuffer", "Hacl.P256.ecdsa_sign_p256_sha2", "LowStar.Monotonic.Buffer.blit", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "Prims.b2t", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame", "Hacl.Test.ECDSA.check_bound", "LowStar.Monotonic.Buffer.recall", "Prims.int", "FStar.Monotonic.HyperStack.mem", "Prims.l_True" ]
[]
false
true
false
false
false
let test_siggen_256 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) =
let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else (push_frame (); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha2 rs msg_len msg d k in if flag then let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then let result = ecdsa_verif_p256_sha2 msg_len msg qxy r s in if not result then ((let open LowStar.Printf in printf "FAIL: verification\n" done); C.exit 1l) else ((let open LowStar.Printf in printf "FAIL: signing\n" done); C.exit 1l) else ((let open LowStar.Printf in printf "FAIL: signing\n" done); C.exit 1l); pop_frame ())
false
Vale.X64.StateLemmas.fst
Vale.X64.StateLemmas.lemma_load_buffer_read64
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)]
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 = lemma_load_mem64 b i h
{ "file_name": "vale/code/arch/x64/Vale.X64.StateLemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 46, "start_col": 0, "start_line": 45 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Arch.HeapImpl.vale_heap", "Vale.X64.Memory.buffer64", "Prims.int", "Vale.X64.Memory.lemma_load_mem64", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_load_buffer_read64 h b i =
lemma_load_mem64 b i h
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.table_inv_w5
val table_inv_w5:BE.table_inv_t U64 15ul 32ul
val table_inv_w5:BE.table_inv_t U64 15ul 32ul
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
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 48, "start_col": 0, "start_line": 41 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (15ul <: FStar.UInt32.t) (32ul <: FStar.UInt32.t)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Test.ECDSA.fst
Hacl.Test.ECDSA.test_siggen_512
val test_siggen_512 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True)
val test_siggen_512 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True)
let test_siggen_512 (vec:siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha512 rs msg_len msg d k in if flag then begin let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then begin let result = ecdsa_verif_p256_sha512 msg_len msg qxy r s in if not result then begin LowStar.Printf.(printf "FAIL: verification\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end; pop_frame() end
{ "file_name": "code/tests/Hacl.Test.ECDSA.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 459, "start_col": 0, "start_line": 397 }
module Hacl.Test.ECDSA open FStar.HyperStack.ST open Test.Lowstarize open Lib.IntTypes open Hacl.P256 open Spec.ECDSA.Test.Vectors module L = Test.Lowstarize module B = LowStar.Buffer #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" noextract let sigver_vectors256_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_256 noextract let sigver_vectors384_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_384 noextract let sigver_vectors512_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_512 noextract let siggen_vectors256_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_256 noextract let siggen_vectors384_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_384 noextract let siggen_vectors512_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_512 %splice[sigver_vectors256_low] (lowstarize_toplevel "sigver_vectors256_tmp" "sigver_vectors256_low") %splice[sigver_vectors384_low] (lowstarize_toplevel "sigver_vectors384_tmp" "sigver_vectors384_low") %splice[sigver_vectors512_low] (lowstarize_toplevel "sigver_vectors512_tmp" "sigver_vectors512_low") %splice[siggen_vectors256_low] (lowstarize_toplevel "siggen_vectors256_tmp" "siggen_vectors256_low") %splice[siggen_vectors384_low] (lowstarize_toplevel "siggen_vectors384_tmp" "siggen_vectors384_low") %splice[siggen_vectors512_low] (lowstarize_toplevel "siggen_vectors512_tmp" "siggen_vectors512_low") // Cheap alternative to friend Lib.IntTypes needed because Test.Lowstarize uses UInt8.t assume val declassify_uint8: squash (uint8 == UInt8.t) let vec8 = L.lbuffer UInt8.t let sigver_vector = vec8 & vec8 & vec8 & vec8 & vec8 & bool let siggen_vector = vec8 & vec8 & vec8 & vec8 & vec8 & vec8 & vec8 // This could replace TestLib.compare_and_print val compare_and_print: b1:B.buffer UInt8.t -> b2:B.buffer UInt8.t -> len:UInt32.t -> Stack bool (requires fun h0 -> B.live h0 b1 /\ B.live h0 b2 /\ B.length b1 == v len /\ B.length b2 == v len) (ensures fun h0 _ h1 -> B.modifies B.loc_none h0 h1) let compare_and_print b1 b2 len = push_frame(); LowStar.Printf.(printf "Expected: %xuy\n" len b1 done); LowStar.Printf.(printf "Computed: %xuy\n" len b2 done); let b = Lib.ByteBuffer.lbytes_eq #len b1 b2 in if b then LowStar.Printf.(printf "PASS\n" done) else LowStar.Printf.(printf "FAIL\n" done); pop_frame(); b let test_sigver256 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha2 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end let test_sigver384 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha384 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end let test_sigver512 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha512 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end #push-options "--fuel 1 --ifuel 1 --z3rlimit 200" val check_bound: b:Lib.Buffer.lbuffer uint8 32ul -> Stack bool (requires fun h -> Lib.Buffer.live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == ( (Lib.ByteSequence.nat_from_bytes_be (Lib.Buffer.as_seq h0 b) > 0) && (Lib.ByteSequence.nat_from_bytes_be (Lib.Buffer.as_seq h0 b) < Spec.P256.order))) let check_bound b = let open FStar.Mul in let open Lib.ByteSequence in let open Spec.P256 in [@inline_let] let q1 = normalize_term (order % pow2 64) in [@inline_let] let q2 = normalize_term ((order / pow2 64) % pow2 64) in [@inline_let] let q3 = normalize_term ((order / pow2 128) % pow2 64) in [@inline_let] let q4 = normalize_term (((order / pow2 128) / pow2 64) % pow2 64) in assert_norm (pow2 128 * pow2 64 == pow2 192); assert (order == q1 + pow2 64 * q2 + pow2 128 * q3 + pow2 192 * q4); let zero = mk_int #U64 #PUB 0 in let q1 = mk_int #U64 #PUB q1 in let q2 = mk_int #U64 #PUB q2 in let q3 = mk_int #U64 #PUB q3 in let q4 = mk_int #U64 #PUB q4 in let h0 = get () in let x1 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 0ul 8ul) in let x2 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 8ul 8ul) in let x3 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 16ul 8ul) in let x4 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 24ul 8ul) in nat_from_intseq_be_slice_lemma (Lib.Buffer.as_seq h0 b) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 0 8); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 8 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 8 16); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 16 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 16 24); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 24 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 24 32); let x1 = Lib.RawIntTypes.u64_to_UInt64 x1 in let x2 = Lib.RawIntTypes.u64_to_UInt64 x2 in let x3 = Lib.RawIntTypes.u64_to_UInt64 x3 in let x4 = Lib.RawIntTypes.u64_to_UInt64 x4 in let r = x1 <. q4 || (x1 =. q4 && (x2 <. q3 || (x2 =. q3 && (x3 <. q2 || (x3 =. q2 && x4 <. q1))))) in let r1 = x1 = zero && x2 = zero && x3 = zero && x4 = zero in r && not r1 #push-options " --ifuel 1 --fuel 1" let test_siggen_256 (vec:siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha2 rs msg_len msg d k in if flag then begin let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then begin let result = ecdsa_verif_p256_sha2 msg_len msg qxy r s in if not result then begin LowStar.Printf.(printf "FAIL: verification\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end; pop_frame() end let test_siggen_384 (vec:siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha384 rs msg_len msg d k in if flag then begin let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then begin let result = ecdsa_verif_p256_sha384 msg_len msg qxy r s in if not result then begin LowStar.Printf.(printf "FAIL: verification\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end; pop_frame() end
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.P256.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "LowStar.Printf.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.P256.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "C.String.fsti.checked", "C.Loops.fst.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.ECDSA.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Test.Lowstarize", "short_module": "L" }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": 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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
vec: Hacl.Test.ECDSA.siggen_vector -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Test.ECDSA.siggen_vector", "FStar.UInt32.t", "LowStar.Buffer.buffer", "FStar.UInt8.t", "Prims.l_and", "Prims.eq2", "LowStar.Monotonic.Buffer.len", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.recallable", "Prims.op_Negation", "Prims.op_AmpAmp", "Prims.op_Equality", "FStar.UInt32.__uint_to_t", "C.exit", "FStar.Int32.__int_to_t", "Prims.unit", "Prims.bool", "FStar.HyperStack.ST.pop_frame", "LowStar.Printf.printf", "LowStar.Printf.done", "Hacl.P256.ecdsa_verif_p256_sha512", "Hacl.Test.ECDSA.compare_and_print", "LowStar.Buffer.sub", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.mbuffer", "Hacl.P256.ecdsa_sign_p256_sha512", "LowStar.Monotonic.Buffer.blit", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "Prims.b2t", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame", "Hacl.Test.ECDSA.check_bound", "LowStar.Monotonic.Buffer.recall", "Prims.int", "FStar.Monotonic.HyperStack.mem", "Prims.l_True" ]
[]
false
true
false
false
false
let test_siggen_512 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) =
let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else (push_frame (); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha512 rs msg_len msg d k in if flag then let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then let result = ecdsa_verif_p256_sha512 msg_len msg qxy r s in if not result then ((let open LowStar.Printf in printf "FAIL: verification\n" done); C.exit 1l) else ((let open LowStar.Printf in printf "FAIL: signing\n" done); C.exit 1l) else ((let open LowStar.Printf in printf "FAIL: signing\n" done); C.exit 1l); pop_frame ())
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.table_inv_w4
val table_inv_w4:BE.table_inv_t U64 15ul 16ul
val table_inv_w4:BE.table_inv_t U64 15ul 16ul
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
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 37, "start_col": 0, "start_line": 31 }
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"
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (15ul <: FStar.UInt32.t) (16ul <: FStar.UInt32.t)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.lemma_exp_four_fw_local
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)))
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))
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 84, "end_line": 159, "start_col": 0, "start_line": 150 }
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)))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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))
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
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))
false
FStar.Stubs.Tactics.V2.Builtins.fsti
FStar.Stubs.Tactics.V2.Builtins.ret_t
val ret_t : a: Type -> Type
let ret_t (a:Type) = option a & issues
{ "file_name": "ulib/FStar.Stubs.Tactics.V2.Builtins.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 479, "start_col": 0, "start_line": 479 }
(* 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. *) (** Every tactic primitive, i.e., those built into the compiler @summary Tactic primitives *) module FStar.Stubs.Tactics.V2.Builtins open FStar.VConfig open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins open FStar.Tactics.Effect open FStar.Tactics.Effect open FStar.Stubs.Tactics.Types include FStar.Tactics.Unseal (** Resolve unification variable indirections at the top of the term. *) val compress : term -> Tac term (** [top_env] returns the environment where the tactic started running. * This works even if no goals are present. *) val top_env : unit -> Tac env (** [fresh ()] returns a fresh number generated by incrementing an internal counter. The counter does not get reset when catching a failure. *) val fresh : unit -> Tac nat (** [refine_intro] will turn a goal of shape [w : x:t{phi}] into [w : t] and [phi{w/x}] *) val refine_intro : unit -> Tac unit (** [tc] returns the type of a term in [env], or fails if it is untypeable. *) val tc : env -> term -> Tac term (** [tcc] like [tc], but returns the full computation type with the effect label and its arguments (WPs, etc) as well *) val tcc : env -> term -> Tac comp (** [unshelve] creates a goal from a term for its given type. It can be used when the system decided not to present a goal, but you want one anyway. For example, if you request a uvar through [uvar_env] or [fresh_uvar], you might want to instantiate it explicitly. *) val unshelve : term -> Tac unit (** [unquote t] with turn a quoted term [t] into an actual value, of any type. This will fail at tactic runtime if the quoted term does not typecheck to type [a]. *) val unquote : #a:Type -> term -> Tac a (** [catch t] will attempt to run [t] and allow to recover from a failure. If [t] succeeds with return value [a], [catch t] returns [Inr a]. On failure, it returns [Inl msg], where [msg] is the error [t] raised, and all unionfind effects are reverted. See also [recover] and [or_else]. *) val catch : #a:Type -> (unit -> Tac a) -> TacS (either exn a) (** Like [catch t], but will not discard unionfind effects on failure. *) val recover : #a:Type -> (unit -> Tac a) -> TacS (either exn a) (** [norm steps] will call the normalizer on the current goal's type and witness, with its reduction behaviour parameterized by the flags in [steps]. Currently, the flags (provided in FStar.Pervasives) are [simpl] (do logical simplifications) [whnf] (only reduce until weak head-normal-form) [primops] (performing primitive reductions, such as arithmetic and string operations) [delta] (unfold names) [zeta] (unroll let rec bindings, but with heuristics to avoid loops) [zeta_full] (unroll let rec bindings fully) [iota] (reduce match statements over constructors) [delta_only] (restrict delta to only unfold this list of fully-qualified identifiers) *) val norm : list norm_step -> Tac unit (** [norm_term_env e steps t] will call the normalizer on the term [t] using the list of steps [steps], over environment [e]. The list has the same meaning as for [norm]. *) val norm_term_env : env -> list norm_step -> term -> Tac term (** [norm_binding_type steps b] will call the normalizer on the type of the [b] binding for the current goal. Notably, this cannot be done via var_retype and norm, because of uvars being resolved to lambda-abstractions. *) val norm_binding_type : list norm_step -> binding -> Tac unit (** [intro] pushes the first argument of an arrow goal into the environment, turning [Gamma |- ?u : x:a -> b] into [Gamma, x:a |- ?u' : b]. Note that this does not work for logical implications/forall. See FStar.Tactics.Logic for that. *) val intro : unit -> Tac binding (** Similar to intros, but allows to build a recursive function. Currently broken (c.f. issue #1103) *) val intro_rec : unit -> Tac (binding * binding) (** [rename_to b nm] will rename the binder [b] to [nm] in the environment, goal, and witness in a safe manner. The only use of this is to make goals and terms more user readable. The primitive returns the new binder, since the old one disappears from the context. *) val rename_to : binding -> string -> Tac binding (** [revert] pushes out a binder from the environment into the goal type, so a behaviour opposite to [intros]. *) val revert : unit -> Tac unit (** [var_retype] changes the type of a variable in the context. After calling it with a binding of type `t`, the user is presented with a goal of the form `t == ?u` to be filled. The original goal (following that one) has the type of `b` in the context replaced by `?u`. *) val var_retype : binding -> Tac unit (** [clear_top] will drop the outermost binder from the environment. Can only be used if the goal does not at all depend on it. *) val clear_top : unit -> Tac unit (** [clear] will drop the given binder from the context, is nothing depends on it. *) val clear : binding -> Tac unit (** If [b] is a binding of type [v == r], [rewrite b] will rewrite the variable [v] for [r] everywhere in the current goal type and witness. *) val rewrite : binding -> Tac unit (** First boolean is whether to attempt to introduce a refinement before solving. In that case, a goal for the refinement formula will be added. Second boolean is whether to set the expected type internally. Just use `exact` from FStar.Tactics.Derived if you don't know what's up with all this. *) val t_exact : maybe_refine:bool -> set_expected_typ:bool -> term -> Tac unit (** Inner primitive for [apply], takes a boolean specifying whether to not ask for implicits that appear free in posterior goals, a boolean specifying whether it's forbidden to instantiate uvars in the goal, and a boolean specifying whether uvars resolved during unification of the goal to the term should be typechecked as part of t_apply If the third boolean is false, those uvars will be typechecked at the end by the tactics engine. Example: when [uopt] is true, applying transitivity to [|- a = c] will give two goals, [|- a = ?u] and [|- ?u = c] without asking to instantiate [?u] since it will most likely be constrained later by solving these goals. In any case, we track [?u] and will fail if it's not solved later. Example: when [noinst] is true, applying a function returning [1 = 2] will fail on a goal of the shape [1 = ?u] since it must instantiate [?u]. We use this in typeclass resolution. You may want [apply] from FStar.Tactics.Derived, or one of the other user facing variants. *) val t_apply : uopt:bool -> noinst:bool -> tc_resolved_uvars:bool -> term -> Tac unit (** [t_apply_lemma ni nilhs l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. For the meaning of the [noinst] boolean arg see [t_apply], briefly, it does not allow to instantiate uvars in the goal. The [noinst_lhs] flag is similar, it forbids instantiating uvars *but only on the LHS of the goal*, provided the goal is an equality. It is meant to be useful for rewrite-goals, of the shape [X = ?u]. Setting [noinst] means [noinst_lhs] is ignored. *) val t_apply_lemma : noinst:bool -> noinst_lhs:bool -> term -> Tac unit // TODO: do the unit thing too for [apply]. (** [print str] has no effect on the proofstate, but will have the side effect of printing [str] on the compiler's standard output. *) val print : string -> Tac unit (** [debugging ()] returns true if the current module has the debug flag on, i.e. when [--debug MyModule --debug_level Tac] was passed in. *) val debugging : unit -> Tac bool (** Similar to [print], but will dump a text representation of the proofstate along with the message. *) val dump : string -> Tac unit (** Similar to [dump], but will print *every* unsolved implicit in the proofstate, not only the visible/focused goals. When the [print_resolved] boolean is true, it will also print every solved goal. Warning, these can be a *lot*. *) val dump_all : print_resolved:bool -> string -> Tac unit (** Will print a goal for every unresolved implicit in the provided goal. *) val dump_uvars_of : goal -> string -> Tac unit (** Solves a goal [Gamma |= squash (l == r)] by attempting to unify [l] with [r]. This currently only exists because of some universe problems when trying to [apply] a reflexivity lemma. When [allow_guards] is [true], it is allowed that (some) guards are raised during the unification process and added as a single goal to be discharged later. Currently, the only guards allowed here are for equating refinement types (e.g. [x:int{x>0}] and [x:int{0<x}]. *) val t_trefl : allow_guards:bool -> Tac unit (** Provides a proof for the equality [(match e with ... | pi -> ei ...) a1 .. an == (match e with ... | pi -> e1 a1 .. an)]. This is particularly useful to rewrite the expression on the left to the one on the right when the RHS is actually a unification variable. *) val t_commute_applied_match : unit -> Tac unit (** In case there are goals that are already solved which have non-trivial typing guards, make those guards as explicit proof obligations in the tactic state, solving any trivial ones by simplification. See tests/bug-reports/Bug2635.fst for some examples Update 11/14/2022: with the introduction of the core typechecker, this primitive should no longer be necessary. Try using the compat pre core flags, or `with_compat_pre_core` primitive if your code breaks without this.*) [@@deprecated "This will soon be removed, please use compat pre core settings if needed"] val gather_or_solve_explicit_guards_for_resolved_goals : unit -> Tac unit (** [ctrl_rewrite] will traverse the current goal, and call [ctrl] * repeatedly on subterms. When [ctrl t] returns [(true, _)], the * tactic will call [rw] with a goal of type [t = ?u], which once * solved will rewrite [t] to the solution of [?u]. No goal is * made if [ctrl t] returns [(false, _)]. * * The second component of the return value of [ctrl] specifies * whether for continue descending in the goal or not. It can * either be: * - Continue: keep on with further subterms * - Skip: stop descending in this tree * - Abort: stop everything * * The first argument is the direction, [TopDown] or [BottomUp]. It * specifies how the AST of the goal is traversed (preorder or postorder). * * Note: for [BottomUp] a [Skip] means to stop trying to rewrite everything * from the current node up to the root, but still consider siblings. This * means that [ctrl_rewrite BottomUp (fun _ -> (true, Skip)) t] will call [t] * for every leaf node in the AST. * * See [pointwise] and [topdown_rewrite] for more friendly versions. *) val ctrl_rewrite : direction -> (ctrl : term -> Tac (bool & ctrl_flag)) -> (rw:unit -> Tac unit) -> Tac unit (** Given the current goal [Gamma |- w : t], [dup] will turn this goal into [Gamma |- ?u : t] and [Gamma |= ?u == w]. It can thus be used to change a goal's witness in any way needed, by choosing some [?u] (possibly with exact) and then solving the other goal. *) val dup : unit -> Tac unit // Proof namespace management (** [prune "A.B.C"] will mark all top-level definitions in module [A.B.C] (and submodules of it) to not be encoded to the SMT, for the current goal. The string is a namespace prefix. [prune ""] will prune everything, but note that [prune "FStar.S"] will not prune ["FStar.Set"]. *) val prune : string -> Tac unit (** The opposite operation of [prune]. The latest one takes precedence. *) val addns : string -> Tac unit (** Destruct a value of an inductive type by matching on it. The generated match has one branch for each constructor and is therefore trivially exhaustive, no VC is generated for that purpose. It returns a list with the fvars of each constructor and their arities, in the order they appear as goals. *) val t_destruct : term -> Tac (list (fv * nat)) (** Set command line options for the current goal. Mostly useful to change SMT encoding options such as [set_options "--z3rlimit 20"]. *) val set_options : string -> Tac unit (** Creates a new, unconstrained unification variable in environment [env]. The type of the uvar can optionally be provided in [o]. If not provided, a second uvar is created for the type. *) val uvar_env : env -> option typ -> Tac term (** Creates a new, unconstrained unification variable in environment [env]. The type of the uvar must be provided and the uvar can be solved to a Ghost term of that type *) val ghost_uvar_env : env -> typ -> Tac term (** Creates a new, unconstrained universe unification variable. The returned term is Type (U_Unif ?u). *) val fresh_universe_uvar : unit -> Tac term (** Call the unifier on two terms. The returned boolean specifies whether unification was possible. When the tactic returns true, the terms have been unified, instantiating uvars as needed. When false, unification was not possible and no change to uvars occurs. *) val unify_env : env -> t1:term -> t2:term -> Tac bool (** Similar to [unify_env], but allows for some guards to be raised during unification (see [t_trefl] for an explanation). Will add a new goal with the guard. *) val unify_guard_env : env -> t1:term -> t2:term -> Tac bool (** Check if [t1] matches [t2], i.e., whether [t2] can have its uvars instantiated into unifying with [t1]. When the tactic returns true, the terms have been unified, instantiating uvars as needed. When false, matching was not possible and no change to uvars occurs. *) val match_env : env -> t1:term -> t2:term -> Tac bool (** Launches an external process [prog] with arguments [args] and input [input] and returns the output. For security reasons, this can only be performed when the `--unsafe_tactic_exec` options was provided for the current F* invocation. The tactic will fail if this is not so. *) val launch_process : string -> list string -> string -> Tac string (** Get a fresh bv of some name and type. The name is only useful for pretty-printing, since there is a fresh inaccessible integer within the bv too. *) (* val fresh_bv_named : string -> Tac bv *) (** Change the goal to another type, given that it is convertible to the current type. *) val change : typ -> Tac unit (** Get the current guard policy. The guard policy specifies what should be done when a VC arises internally from the tactic engine. Options are SMT (mark it as an SMT goal), Goal (add it as an extra goal) and Force (only allow trivial guards, that need no SMT. *) val get_guard_policy : unit -> Tac guard_policy (** Set the current guard policy. See [get_guard_policy} for an explanation *) val set_guard_policy : guard_policy -> Tac unit (** [lax_on] returns true iff the current environment has the `--lax` option set, and thus drops all verification conditions. *) val lax_on : unit -> Tac bool (** Admit the current goal and set the witness to the given term. Absolutely unsafe. Raises a warning. *) val tadmit_t : term -> Tac unit (** Join the first two goals, which must be irrelevant, in a single one by finding a maximal prefix of their environment and reverting appropriately. Useful to minimize SMT queries that share internal obligations. *) val join : unit -> Tac unit (* Local metastate via a string-keyed map. [lget] fails if the found element is not typeable at the requested type. *) val lget : #a:Type -> string -> Tac a val lset : #a:Type -> string -> a -> Tac unit (** Set the current set of active goals at will. Obligations remain in the implicits. *) val set_goals : list goal -> Tac unit (** Set the current set of SMT goals at will. Obligations remain in the implicits. TODO: This is a really bad name, there's no special "SMT" about these goals. *) val set_smt_goals : list goal -> Tac unit (** [curms ()] returns the current (wall) time in milliseconds *) val curms : unit -> Tac int (** [set_urgency u] sets the urgency of error messages. Usually set just before raising an exception (see e.g. [fail_silently]). *) val set_urgency : int -> TacS unit (** [string_to_term e s] runs the F* parser on the string [s] in the environment [e], and produces a term. *) val string_to_term : env -> string -> Tac term (** [push_bv_dsenv e id] pushes a identifier [id] into the parsing environment of [e] an environment. It returns a new environment that has the identifier [id] along with its corresponding binding. *) val push_bv_dsenv : env -> string -> Tac (env * binding) (** Print a term via the pretty printer. This is considered effectful since 1) setting options can change the behavior of this function, and hence is not really pure; and 2) this function could expose details of the term representation that do not show up in the view, invalidating the pack_inspect_inv/inspeck_pack_inv lemmas. *) val term_to_string : term -> Tac string (** Print a computation type via the pretty printer. See comment on [term_to_string]. *) val comp_to_string : comp -> Tac string (** Like term_to_string, but returns an unrendered pretty-printing document *) val term_to_doc : term -> Tac Stubs.Pprint.document (** Like comp_to_string, but returns an unrendered pretty-printing document *) val comp_to_doc : comp -> Tac Stubs.Pprint.document (** Print a source range as a string *) val range_to_string : range -> Tac string (** A variant of Reflection.term_eq that may inspect more underlying details of terms. This function could distinguish two _otherwise equal terms_, but that distinction cannot leave the Tac effect. This is only exposed as a migration path. Please use [Reflection.term_eq] instead. *) [@@deprecated "Use Reflection.term_eq instead"] val term_eq_old : term -> term -> Tac bool (** Runs the input tactic `f` with compat pre core setting `n`. It is an escape hatch for maintaining backward compatibility for code that breaks with the core typechecker. *) val with_compat_pre_core : #a:Type -> n:int -> f:(unit -> Tac a) -> Tac a (** Get the [vconfig], including fuel, ifuel, rlimit, etc, associated with the current goal. *) val get_vconfig : unit -> Tac vconfig (** Set the [vconfig], including fuel, ifuel, rlimit, etc, associated with the current goal. This vconfig will be used if the goal is attempted by SMT at the end of a tactic run. *) val set_vconfig : vconfig -> Tac unit (** Attempt to solve the current goal with SMT immediately, and fail if it cannot be solved. The vconfig specifies fuels, limits, etc. The current goal's vconfig is ignored in favor of this one. *) val t_smt_sync : vconfig -> Tac unit (** This returns the free uvars that appear in a term. This is not a reflection primitive as it depends on the state of the UF graph. *) val free_uvars : term -> Tac (list int) (* Return all k/v pairs in the state. The order is unspecified, do not rely on it. *) val all_ext_options : unit -> Tac (list (string & string)) (* Lookup a k/v pair in the --ext option state. The empty string is returned if the key was unset. *) val ext_getv (k:string) : Tac string (* Return all k/v pairs in the state which are within the given namespace. *) val ext_getns (ns:string) : Tac (list (string & string)) (** The following primitives provide support for local state during execution of a tactic. The local state is monotonic, it is not reverted when the tactic backtracks (using catch e.g.) *) val alloc (#a:Type) (x:a) : Tac (tref a) val read (#a:Type) (r:tref a) : Tac a val write (#a:Type) (r:tref a) (x:a) : Tac unit (***** APIs used in the meta DSL framework *****) (** Meta DSL framework is an experimental feature See examples/dsls/ for more details Following APIs are part of the framework *) (** TODO: maybe the equiv APIs should require typing of the arguments? *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Unseal.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Issue.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "FStar.Stubs.Tactics.V2.Builtins.fsti" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Unseal", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.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 } ]
{ "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" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "FStar.Stubs.Tactics.Types.issues" ]
[]
false
false
false
true
true
let ret_t (a: Type) =
option a & issues
false
Hacl.Test.ECDSA.fst
Hacl.Test.ECDSA.test_siggen_384
val test_siggen_384 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True)
val test_siggen_384 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True)
let test_siggen_384 (vec:siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha384 rs msg_len msg d k in if flag then begin let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then begin let result = ecdsa_verif_p256_sha384 msg_len msg qxy r s in if not result then begin LowStar.Printf.(printf "FAIL: verification\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end; pop_frame() end
{ "file_name": "code/tests/Hacl.Test.ECDSA.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 394, "start_col": 0, "start_line": 332 }
module Hacl.Test.ECDSA open FStar.HyperStack.ST open Test.Lowstarize open Lib.IntTypes open Hacl.P256 open Spec.ECDSA.Test.Vectors module L = Test.Lowstarize module B = LowStar.Buffer #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" noextract let sigver_vectors256_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_256 noextract let sigver_vectors384_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_384 noextract let sigver_vectors512_tmp = List.Tot.map (fun x -> h x.msg, h x.qx, h x.qy, h x.r, h x.s, x.result) sigver_vectors_sha2_512 noextract let siggen_vectors256_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_256 noextract let siggen_vectors384_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_384 noextract let siggen_vectors512_tmp = List.Tot.map (fun x -> h x.msg', h x.d, h x.qx', h x.qy', h x.k, h x.r', h x.s') siggen_vectors_sha2_512 %splice[sigver_vectors256_low] (lowstarize_toplevel "sigver_vectors256_tmp" "sigver_vectors256_low") %splice[sigver_vectors384_low] (lowstarize_toplevel "sigver_vectors384_tmp" "sigver_vectors384_low") %splice[sigver_vectors512_low] (lowstarize_toplevel "sigver_vectors512_tmp" "sigver_vectors512_low") %splice[siggen_vectors256_low] (lowstarize_toplevel "siggen_vectors256_tmp" "siggen_vectors256_low") %splice[siggen_vectors384_low] (lowstarize_toplevel "siggen_vectors384_tmp" "siggen_vectors384_low") %splice[siggen_vectors512_low] (lowstarize_toplevel "siggen_vectors512_tmp" "siggen_vectors512_low") // Cheap alternative to friend Lib.IntTypes needed because Test.Lowstarize uses UInt8.t assume val declassify_uint8: squash (uint8 == UInt8.t) let vec8 = L.lbuffer UInt8.t let sigver_vector = vec8 & vec8 & vec8 & vec8 & vec8 & bool let siggen_vector = vec8 & vec8 & vec8 & vec8 & vec8 & vec8 & vec8 // This could replace TestLib.compare_and_print val compare_and_print: b1:B.buffer UInt8.t -> b2:B.buffer UInt8.t -> len:UInt32.t -> Stack bool (requires fun h0 -> B.live h0 b1 /\ B.live h0 b2 /\ B.length b1 == v len /\ B.length b2 == v len) (ensures fun h0 _ h1 -> B.modifies B.loc_none h0 h1) let compare_and_print b1 b2 len = push_frame(); LowStar.Printf.(printf "Expected: %xuy\n" len b1 done); LowStar.Printf.(printf "Computed: %xuy\n" len b2 done); let b = Lib.ByteBuffer.lbytes_eq #len b1 b2 in if b then LowStar.Printf.(printf "PASS\n" done) else LowStar.Printf.(printf "FAIL\n" done); pop_frame(); b let test_sigver256 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha2 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end let test_sigver384 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha384 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end let test_sigver512 (vec:sigver_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB qx_len qx, LB qy_len qy, LB r_len r, LB s_len s, result = vec in B.recall msg; B.recall qx; B.recall qy; B.recall r; B.recall s; // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let result' = ecdsa_verif_p256_sha512 msg_len msg qxy r s in if result' = result then () else begin LowStar.Printf.(printf "FAIL\n" done); C.exit 1l end; pop_frame() end #push-options "--fuel 1 --ifuel 1 --z3rlimit 200" val check_bound: b:Lib.Buffer.lbuffer uint8 32ul -> Stack bool (requires fun h -> Lib.Buffer.live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == ( (Lib.ByteSequence.nat_from_bytes_be (Lib.Buffer.as_seq h0 b) > 0) && (Lib.ByteSequence.nat_from_bytes_be (Lib.Buffer.as_seq h0 b) < Spec.P256.order))) let check_bound b = let open FStar.Mul in let open Lib.ByteSequence in let open Spec.P256 in [@inline_let] let q1 = normalize_term (order % pow2 64) in [@inline_let] let q2 = normalize_term ((order / pow2 64) % pow2 64) in [@inline_let] let q3 = normalize_term ((order / pow2 128) % pow2 64) in [@inline_let] let q4 = normalize_term (((order / pow2 128) / pow2 64) % pow2 64) in assert_norm (pow2 128 * pow2 64 == pow2 192); assert (order == q1 + pow2 64 * q2 + pow2 128 * q3 + pow2 192 * q4); let zero = mk_int #U64 #PUB 0 in let q1 = mk_int #U64 #PUB q1 in let q2 = mk_int #U64 #PUB q2 in let q3 = mk_int #U64 #PUB q3 in let q4 = mk_int #U64 #PUB q4 in let h0 = get () in let x1 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 0ul 8ul) in let x2 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 8ul 8ul) in let x3 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 16ul 8ul) in let x4 = Lib.ByteBuffer.uint_from_bytes_be #U64 (Lib.Buffer.sub b 24ul 8ul) in nat_from_intseq_be_slice_lemma (Lib.Buffer.as_seq h0 b) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 0 8); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 8 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 8 16); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 16 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 16 24); nat_from_intseq_be_slice_lemma (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 24 32) 8; lemma_reveal_uint_to_bytes_be #U64 (Lib.Sequence.slice (Lib.Buffer.as_seq h0 b) 24 32); let x1 = Lib.RawIntTypes.u64_to_UInt64 x1 in let x2 = Lib.RawIntTypes.u64_to_UInt64 x2 in let x3 = Lib.RawIntTypes.u64_to_UInt64 x3 in let x4 = Lib.RawIntTypes.u64_to_UInt64 x4 in let r = x1 <. q4 || (x1 =. q4 && (x2 <. q3 || (x2 =. q3 && (x3 <. q2 || (x3 =. q2 && x4 <. q1))))) in let r1 = x1 = zero && x2 = zero && x3 = zero && x4 = zero in r && not r1 #push-options " --ifuel 1 --fuel 1" let test_siggen_256 (vec:siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) = let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in // We need to check this at runtime because Low*-ized vectors don't carry any refinements if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else begin push_frame(); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha2 rs msg_len msg d k in if flag then begin let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then begin let result = ecdsa_verif_p256_sha2 msg_len msg qxy r s in if not result then begin LowStar.Printf.(printf "FAIL: verification\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end end else begin LowStar.Printf.(printf "FAIL: signing\n" done); C.exit 1l end; pop_frame() end
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.P256.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "LowStar.Printf.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.P256.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "C.String.fsti.checked", "C.Loops.fst.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.ECDSA.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Test.Lowstarize", "short_module": "L" }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "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": 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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
vec: Hacl.Test.ECDSA.siggen_vector -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Test.ECDSA.siggen_vector", "FStar.UInt32.t", "LowStar.Buffer.buffer", "FStar.UInt8.t", "Prims.l_and", "Prims.eq2", "LowStar.Monotonic.Buffer.len", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.recallable", "Prims.op_Negation", "Prims.op_AmpAmp", "Prims.op_Equality", "FStar.UInt32.__uint_to_t", "C.exit", "FStar.Int32.__int_to_t", "Prims.unit", "Prims.bool", "FStar.HyperStack.ST.pop_frame", "LowStar.Printf.printf", "LowStar.Printf.done", "Hacl.P256.ecdsa_verif_p256_sha384", "Hacl.Test.ECDSA.compare_and_print", "LowStar.Buffer.sub", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.mbuffer", "Hacl.P256.ecdsa_sign_p256_sha384", "LowStar.Monotonic.Buffer.blit", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "Prims.b2t", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame", "Hacl.Test.ECDSA.check_bound", "LowStar.Monotonic.Buffer.recall", "Prims.int", "FStar.Monotonic.HyperStack.mem", "Prims.l_True" ]
[]
false
true
false
false
false
let test_siggen_384 (vec: siggen_vector) : Stack unit (requires fun _ -> True) (ensures fun _ _ _ -> True) =
let max_msg_len = 0 in let LB msg_len msg, LB d_len d, LB qx_len qx, LB qy_len qy, LB k_len k, LB r_len r, LB s_len s = vec in B.recall msg; B.recall d; B.recall qx; B.recall qy; B.recall k; B.recall r; B.recall s; if not (k_len = 32ul && d_len = 32ul) then C.exit (-1l); let bound_k = check_bound k in let bound_d = check_bound d in if not (bound_k && bound_d && qx_len = 32ul && qy_len = 32ul && r_len = 32ul && s_len = 32ul) then C.exit (-1l) else (push_frame (); let rs = B.alloca (u8 0) 64ul in let qxy = B.alloca (u8 0) 64ul in B.blit qx 0ul qxy 0ul 32ul; B.blit qy 0ul qxy 32ul 32ul; let flag = ecdsa_sign_p256_sha384 rs msg_len msg d k in if flag then let okr = compare_and_print (B.sub rs 0ul 32ul) r 32ul in let oks = compare_and_print (B.sub rs 32ul 32ul) s 32ul in if okr && oks then let result = ecdsa_verif_p256_sha384 msg_len msg qxy r s in if not result then ((let open LowStar.Printf in printf "FAIL: verification\n" done); C.exit 1l) else ((let open LowStar.Printf in printf "FAIL: signing\n" done); C.exit 1l) else ((let open LowStar.Printf in printf "FAIL: signing\n" done); C.exit 1l); pop_frame ())
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.point_mul
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)))
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 = 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
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 93, "end_line": 54, "start_col": 0, "start_line": 51 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
out: Hacl.Impl.K256.Point.point -> scalar: Hacl.K256.Scalar.qelem -> q: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.precomp_get_consttime
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)
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 = [@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
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 67, "start_col": 0, "start_line": 60 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.allP
val allP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (l: list a {l << top \/ l === top}) : Type0
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 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 28, "start_col": 0, "start_line": 25 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
top: b -> pred: (x: a{x << top} -> Type0) -> l: Prims.list a {l << top \/ l === top} -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.precedes", "Prims.list", "Prims.l_or", "Prims.op_Equals_Equals_Equals", "Prims.l_True", "Prims.l_and", "FStar.Reflection.V2.TermEq.allP" ]
[ "recursion" ]
false
false
false
false
true
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
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.optP0
val optP0 (#a: _) (pred: (a -> Type0)) (o: option a) : Type0
val optP0 (#a: _) (pred: (a -> Type0)) (o: option a) : Type0
let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 33, "start_col": 0, "start_line": 30 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
pred: (_: a -> Type0) -> o: FStar.Pervasives.Native.option a -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.option", "Prims.l_True" ]
[]
false
false
false
true
true
let optP0 #a (pred: (a -> Type0)) (o: option a) : Type0 =
match o with | None -> True | Some x -> pred x
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.opt_cmp
val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a)
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 129, "start_col": 0, "start_line": 125 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
cmp: FStar.Reflection.V2.TermEq.comparator_for a -> FStar.Reflection.V2.TermEq.comparator_for (FStar.Pervasives.Native.option a)
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let opt_cmp cmp o1 o2 =
match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.namedv_cmp
val namedv_cmp : comparator_for namedv
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 114, "start_col": 0, "start_line": 108 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.namedv
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.namedv", "Prims.op_Equality", "Prims.nat", "FStar.Stubs.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.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V2.Data.__proj__Mknamedv_view__item__sort", "FStar.Stubs.Reflection.V2.Builtins.pack_inspect_namedv", "FStar.Stubs.Reflection.V2.Data.namedv_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_namedv" ]
[]
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.valid
val valid : c: FStar.Reflection.V2.TermEq._cmpres -> x: t -> y: t -> Prims.logical
let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 82, "start_col": 0, "start_line": 78 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
c: FStar.Reflection.V2.TermEq._cmpres -> x: t -> y: t -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.TermEq._cmpres", "Prims.eq2", "Prims.l_not", "Prims.l_True", "Prims.logical" ]
[]
false
false
false
true
true
let valid #t (c: _cmpres) (x: t) (y: t) =
match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.allP0
val allP0 (#a: _) (pred: (a -> Type0)) (l: list a) : Type0
val allP0 (#a: _) (pred: (a -> Type0)) (l: list a) : Type0
let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 23, "start_col": 0, "start_line": 20 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
pred: (_: a -> Type0) -> l: Prims.list a -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Prims.l_True", "Prims.l_and", "FStar.Reflection.V2.TermEq.allP0" ]
[ "recursion" ]
false
false
false
true
true
let rec allP0 #a (pred: (a -> Type0)) (l: list a) : Type0 =
match l with | [] -> True | x :: xs -> pred x /\ allP0 pred xs
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.optP
val optP (#a #b: _) (top: b) (pred: (x: a{x << top} -> Type0)) (o: option a {o << top}) : Type0
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 = match o with | None -> True | Some x -> pred x
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 38, "start_col": 0, "start_line": 35 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
top: b -> pred: (x: a{x << top} -> Type0) -> o: FStar.Pervasives.Native.option a {o << top} -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.precedes", "FStar.Pervasives.Native.option", "Prims.l_True" ]
[]
false
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.bv_cmp
val bv_cmp : comparator_for bv
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 105, "start_col": 0, "start_line": 99 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.bv
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.bv", "Prims.op_Equality", "Prims.nat", "FStar.Stubs.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.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V2.Data.__proj__Mkbv_view__item__sort", "FStar.Stubs.Reflection.V2.Builtins.pack_inspect_bv", "FStar.Stubs.Reflection.V2.Data.bv_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_bv" ]
[]
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.either_cmp
val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b)
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 136, "start_col": 0, "start_line": 132 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.fv_cmp
val fv_cmp : comparator_for fv
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 122, "start_col": 0, "start_line": 117 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.fv
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.fv", "Prims.op_Equality", "FStar.Stubs.Reflection.Types.name", "FStar.Reflection.V2.TermEq.Eq", "Prims.bool", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "Prims.unit", "FStar.Stubs.Reflection.V2.Builtins.pack_inspect_fv" ]
[]
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.memP_allP0
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)]
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)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 95, "end_line": 56, "start_col": 0, "start_line": 49 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.ident_cmp
val ident_cmp : comparator_for ident
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)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 197, "start_col": 0, "start_line": 191 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.ident
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.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.Stubs.Reflection.V2.Builtins.pack_inspect_ident", "FStar.Stubs.Reflection.V2.Data.ident_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_ident", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
false
false
false
true
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)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.list_dec_cmp
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
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 158, "start_col": 0, "start_line": 154 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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} ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[ "recursion" ]
false
false
false
false
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.pair_cmp
val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b)
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 140, "start_col": 0, "start_line": 139 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
cmpa: FStar.Reflection.V2.TermEq.comparator_for a -> cmpb: FStar.Reflection.V2.TermEq.comparator_for b -> FStar.Reflection.V2.TermEq.comparator_for (a * b)
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let pair_cmp cmpa cmpb (a1, b1) (a2, b2) =
cmpa a1 a2 &&& cmpb b1 b2
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.defined
val defined : r: FStar.Reflection.V2.TermEq._cmpres -> Prims.logical
let defined r = ~(Unknown? r)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 381, "start_col": 0, "start_line": 381 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
r: FStar.Reflection.V2.TermEq._cmpres -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.TermEq._cmpres", "Prims.l_not", "Prims.b2t", "FStar.Reflection.V2.TermEq.uu___is_Unknown", "Prims.logical" ]
[]
false
false
false
true
true
let defined r =
~(Unknown? r)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.memP_dec
val memP_dec (#a: _) (x: a) (l: list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)]
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)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 88, "end_line": 65, "start_col": 0, "start_line": 58 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.memP_allP
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)]
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)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 98, "end_line": 47, "start_col": 0, "start_line": 40 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.def2
val def2 : f: (_: _ -> _: _ -> FStar.Reflection.V2.TermEq._cmpres) -> l1: Prims.list _ -> l2: Prims.list _ -> Prims.logical
let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y))
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 383, "start_col": 0, "start_line": 383 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
f: (_: _ -> _: _ -> FStar.Reflection.V2.TermEq._cmpres) -> l1: Prims.list _ -> l2: Prims.list _ -> Prims.logical
Prims.Tot
[ "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" ]
[]
false
false
false
true
true
let def2 f l1 l2 =
(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y))
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.list_cmp
val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a)
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 147, "start_col": 0, "start_line": 143 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
cmp: FStar.Reflection.V2.TermEq.comparator_for a -> FStar.Reflection.V2.TermEq.comparator_for (Prims.list a)
Prims.Tot
[ "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" ]
[ "recursion" ]
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.eq_cmp
val eq_cmp : #a:eqtype -> comparator_for a
val eq_cmp : #a:eqtype -> comparator_for a
let eq_cmp x y = if x = y then Eq else Neq
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 183, "start_col": 0, "start_line": 183 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for a
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "Prims.op_Equality", "FStar.Reflection.V2.TermEq.Eq", "Prims.bool", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
false
false
false
false
false
let eq_cmp x y =
if x = y then Eq else Neq
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.opt_dec_cmp
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
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 168, "start_col": 0, "start_line": 164 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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} ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.range_cmp
val range_cmp : comparator_for range
val range_cmp : comparator_for range
let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 4, "end_line": 188, "start_col": 0, "start_line": 186 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Range.range
Prims.Tot
[ "total" ]
[]
[ "FStar.Range.range", "FStar.Reflection.V2.TermEq.Eq", "Prims.unit", "FStar.Sealed.sealed_singl", "FStar.Range.__range", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
false
false
false
true
false
let range_cmp r1 r2 =
Sealed.sealed_singl r1 r2; Eq
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.either_dec_cmp
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
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 180, "start_col": 0, "start_line": 176 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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} ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.univ_cmp
val univ_cmp : comparator_for universe
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 213, "start_col": 0, "start_line": 200 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.universe
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.universe_view", "FStar.Reflection.V2.TermEq.Eq", "FStar.Reflection.V2.TermEq.univ_cmp", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Reflection.V2.TermEq.list_dec_cmp", "Prims.nat", "FStar.Reflection.V2.TermEq.eq_cmp", "FStar.Stubs.Reflection.Types.univ_name", "FStar.Reflection.V2.TermEq.ident_cmp", "FStar.Stubs.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.Stubs.Reflection.V2.Builtins.inspect_universe", "Prims.unit", "FStar.Stubs.Reflection.V2.Builtins.pack_inspect_universe" ]
[ "recursion" ]
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.ctxu_cmp
val ctxu_cmp : comparator_for ctx_uvar_and_subst
val ctxu_cmp : comparator_for ctx_uvar_and_subst
let ctxu_cmp _ _ = Unknown
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 230, "start_col": 0, "start_line": 230 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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...? *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.ctx_uvar_and_subst
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.ctx_uvar_and_subst", "FStar.Reflection.V2.TermEq.Unknown", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
false
false
false
true
false
let ctxu_cmp _ _ =
Unknown
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.const_cmp
val const_cmp : comparator_for vconst
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 226, "start_col": 0, "start_line": 216 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.V2.Data.vconst
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.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.Stubs.Reflection.Types.name", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[]
false
false
false
true
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_univ_UvMax
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)
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) = assert_norm (faithful_univ u <==> allP u faithful_univ us)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 417, "start_col": 0, "start_line": 414 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
u268: FStar.Stubs.Reflection.Types.universe -> us: Prims.list FStar.Stubs.Reflection.Types.universe -> FStar.Pervasives.Lemma (requires FStar.Stubs.Reflection.V2.Builtins.inspect_universe u268 == FStar.Stubs.Reflection.V2.Data.Uv_Max us /\ FStar.Reflection.V2.TermEq.faithful_univ u268) (ensures FStar.Reflection.V2.TermEq.allP u268 FStar.Reflection.V2.TermEq.faithful_univ us)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.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.Stubs.Reflection.V2.Data.universe_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Max", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
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)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_term
val faithful_term : Type0
let faithful_term = t:term{faithful t}
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 815, "start_col": 0, "start_line": 815 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.TermEq.faithful" ]
[]
false
false
false
true
true
let faithful_term =
t: term{faithful t}
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_universe
val faithful_universe : Type0
let faithful_universe = t:universe{faithful_univ t}
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 828, "start_col": 0, "start_line": 828 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.faithful_univ" ]
[]
false
false
false
true
true
let faithful_universe =
t: universe{faithful_univ t}
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.defined_list
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))
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 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 | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 390, "start_col": 0, "start_line": 385 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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))
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
false
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)) =
match l1, l2 with | [], [] -> () | x :: xs, y :: ys -> defined_list f xs ys | _ -> ()
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_univ
val faithful_univ : universe -> Type0
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 412, "start_col": 0, "start_line": 402 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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 | _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
u262: FStar.Stubs.Reflection.Types.universe -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.V2.Builtins.inspect_universe", "FStar.Stubs.Reflection.Types.universe_uvar", "Prims.l_False", "Prims.l_True", "Prims.nat", "FStar.Stubs.Reflection.Types.univ_name", "FStar.Reflection.V2.TermEq.faithful_univ", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Reflection.V2.TermEq.allP" ]
[ "recursion" ]
false
false
false
true
true
let rec faithful_univ (u: universe) =
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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.univ_eq_UvMax
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)
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) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 71, "end_line": 423, "start_col": 0, "start_line": 419 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> us1: Prims.list FStar.Stubs.Reflection.Types.universe -> us2: Prims.list FStar.Stubs.Reflection.Types.universe -> FStar.Pervasives.Lemma (requires FStar.Stubs.Reflection.V2.Builtins.inspect_universe u1 == FStar.Stubs.Reflection.V2.Data.Uv_Max us1 /\ FStar.Stubs.Reflection.V2.Builtins.inspect_universe u2 == FStar.Stubs.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)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.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.Stubs.Reflection.V2.Data.universe_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Max", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
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)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_Pat_Cons
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)
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) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 589, "start_col": 0, "start_line": 586 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
p: FStar.Stubs.Reflection.V2.Data.pattern -> f: FStar.Stubs.Reflection.Types.fv -> ous: FStar.Pervasives.Native.option FStar.Stubs.Reflection.V2.Data.universes -> subpats: Prims.list (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) -> FStar.Pervasives.Lemma (requires p == FStar.Stubs.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)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Stubs.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Stubs.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.Stubs.Reflection.V2.Data.Pat_Cons", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
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)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_Tv_Match
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)
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 : 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)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 574, "start_col": 0, "start_line": 571 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> sc: FStar.Stubs.Reflection.Types.term -> o: FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.match_returns_ascription -> brs: Prims.list FStar.Stubs.Reflection.V2.Data.branch -> FStar.Pervasives.Lemma (requires FStar.Stubs.Reflection.V2.Builtins.inspect_ln t == FStar.Stubs.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)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.match_returns_ascription", "Prims.list", "FStar.Stubs.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.Stubs.Reflection.V2.Data.term_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Match", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
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) =
assert_norm (faithful t ==> allP t faithful_branch brs)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.defined_list_dec
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))
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 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 | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 399, "start_col": 0, "start_line": 392 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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 | _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
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))
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
false
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)) =
match l1, l2 with | [], [] -> () | x :: xs, y :: ys -> defined_list_dec t1 t2 f xs ys | _ -> ()
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.univ_faithful_lemma
val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2))
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 453, "start_col": 0, "start_line": 426 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_univ u1 /\ FStar.Reflection.V2.TermEq.faithful_univ u2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.univ_cmp u1 u2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "univ_faithful_lemma", "univ_faithful_lemma_list" ]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.universe_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_universe", "FStar.Reflection.V2.TermEq.univ_faithful_lemma", "FStar.Stubs.Reflection.V2.Data.universes", "Prims.unit", "FStar.Reflection.V2.TermEq.univ_eq_UvMax", "FStar.Reflection.V2.TermEq.univ_faithful_lemma_list", "FStar.Reflection.V2.TermEq.faithful_univ_UvMax", "Prims.nat", "FStar.Stubs.Reflection.Types.univ_name", "FStar.Pervasives.Native.tuple2" ]
[ "mutual recursion" ]
false
false
true
false
false
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 _ -> () | _ -> ()
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_binder
val faithful_binder (b: binder) : Type0
val faithful_binder (b: binder) : 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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
b: FStar.Stubs.Reflection.Types.binder -> Type0
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.V2.Builtins.inspect_binder", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V2.Data.aqualv", "Prims.list", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.ppname_t", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful", "FStar.Reflection.V2.TermEq.faithful_qual", "FStar.Reflection.V2.TermEq.faithful_attrs" ]
[ "mutual recursion" ]
false
false
false
true
true
let rec faithful_binder (b: binder) : Type0 =
match inspect_binder b with | { sort = sort ; qual = q ; attrs = attrs } -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.univ_eq
val univ_eq (u1 u2: universe) : (b: bool{b ==> u1 == u2})
val univ_eq (u1 u2: universe) : (b: bool{b ==> u1 == u2})
let univ_eq (u1 u2 : universe) : (b:bool{b ==> u1 == u2}) = Eq? (univ_cmp u1 u2)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 830, "start_col": 0, "start_line": 829 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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 *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> b: Prims.bool{b ==> u1 == u2}
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.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" ]
[]
false
false
false
false
false
let univ_eq (u1 u2: universe) : (b: bool{b ==> u1 == u2}) =
Eq? (univ_cmp u1 u2)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.univ_faithful_lemma_list
val 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)
val 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)
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 453, "start_col": 0, "start_line": 426 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
u1: b -> u2: b -> us1: Prims.list FStar.Stubs.Reflection.Types.universe {us1 << u1} -> us2: Prims.list FStar.Stubs.Reflection.Types.universe {us2 << u2} -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.allP u1 FStar.Reflection.V2.TermEq.faithful_univ us1 /\ FStar.Reflection.V2.TermEq.allP u2 FStar.Reflection.V2.TermEq.faithful_univ us2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.list_dec_cmp u1 u2 FStar.Reflection.V2.TermEq.univ_cmp us1 us2)) (decreases us1)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "univ_faithful_lemma", "univ_faithful_lemma_list" ]
[ "Prims.list", "FStar.Stubs.Reflection.Types.universe", "Prims.precedes", "FStar.Reflection.V2.TermEq.defined_list_dec", "FStar.Reflection.V2.TermEq.univ_cmp", "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "FStar.List.Tot.Base.memP", "FStar.Reflection.V2.TermEq.defined", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.Reflection.V2.TermEq.univ_faithful_lemma", "FStar.Reflection.V2.TermEq.allP", "FStar.Reflection.V2.TermEq.faithful_univ", "FStar.Reflection.V2.TermEq.list_dec_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec univ_faithful_lemma_list #b (u1: b) (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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.term_eq_dec
val term_eq_dec (t1 t2: faithful_term) : (b: bool{b <==> 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}) = faithful_lemma t1 t2; Eq? (term_cmp t1 t2)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 825, "start_col": 0, "start_line": 823 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
t1: FStar.Reflection.V2.TermEq.faithful_term -> t2: FStar.Reflection.V2.TermEq.faithful_term -> b: Prims.bool{b <==> t1 == t2}
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let term_eq_dec (t1 t2: faithful_term) : (b: bool{b <==> t1 == t2}) =
faithful_lemma t1 t2; Eq? (term_cmp t1 t2)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful
val faithful : term -> Type0
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> Type0
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.namedv", "Prims.l_True", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.V2.Data.vconst", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Reflection.V2.TermEq.allP", "FStar.Stubs.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.faithful_univ", "Prims.l_False", "FStar.Stubs.Reflection.V2.Data.argv", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful", "FStar.Reflection.V2.TermEq.faithful_arg", "FStar.Stubs.Reflection.Types.binder", "FStar.Reflection.V2.TermEq.faithful_binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Reflection.V2.TermEq.faithful_comp", "FStar.Stubs.Reflection.V2.Data.simple_binder", "Prims.nat", "FStar.Stubs.Reflection.Types.ctx_uvar_and_subst", "Prims.bool", "Prims.list", "FStar.Reflection.V2.TermEq.faithful_attrs", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.match_returns_ascription", "FStar.Stubs.Reflection.V2.Data.branch", "Prims.b2t", "FStar.Pervasives.Native.uu___is_None", "FStar.Reflection.V2.TermEq.faithful_branch", "FStar.Reflection.V2.TermEq.optP" ]
[ "mutual recursion" ]
false
false
false
true
true
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 /\ 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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_comp
val faithful_comp : c: FStar.Stubs.Reflection.Types.comp -> Prims.logical
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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
c: FStar.Stubs.Reflection.Types.comp -> Prims.logical
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V2.Builtins.inspect_comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Reflection.V2.TermEq.faithful", "FStar.Stubs.Reflection.Types.term", "Prims.l_and", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.Types.name", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Reflection.V2.TermEq.allP", "FStar.Stubs.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.faithful_univ", "FStar.Reflection.V2.TermEq.faithful_arg", "Prims.logical" ]
[ "mutual recursion" ]
false
false
false
true
true
let rec 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
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_pattern_arg
val faithful_pattern_arg (pb: (pattern * bool)) : Type0
val faithful_pattern_arg (pb: (pattern * bool)) : 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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
pb: (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) -> Type0
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.pattern", "Prims.bool", "FStar.Reflection.V2.TermEq.faithful_pattern", "FStar.Pervasives.Native.fst" ]
[ "mutual recursion" ]
false
false
false
true
true
let rec faithful_pattern_arg (pb: pattern * bool) : Type0 =
faithful_pattern (fst pb)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_arg
val faithful_arg (a: argv) : Type0
val faithful_arg (a: argv) : 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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
a: FStar.Stubs.Reflection.V2.Data.argv -> Type0
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.argv", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful", "FStar.Pervasives.Native.fst", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.TermEq.faithful_qual", "FStar.Pervasives.Native.snd" ]
[ "mutual recursion" ]
false
false
false
true
true
let rec faithful_arg (a: argv) : Type0 =
faithful (fst a) /\ faithful_qual (snd a)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.univ_eq_dec
val univ_eq_dec (u1 u2: faithful_universe) : (b: bool{b <==> 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}) = univ_faithful_lemma u1 u2; Eq? (univ_cmp u1 u2)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 833, "start_col": 0, "start_line": 831 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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}) =
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
u1: FStar.Reflection.V2.TermEq.faithful_universe -> u2: FStar.Reflection.V2.TermEq.faithful_universe -> b: Prims.bool{b <==> u1 == u2}
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let univ_eq_dec (u1 u2: faithful_universe) : (b: bool{b <==> u1 == u2}) =
univ_faithful_lemma u1 u2; Eq? (univ_cmp u1 u2)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.pat_eq_Pat_Cons
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))
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)) = 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))
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 84, "end_line": 598, "start_col": 0, "start_line": 591 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
p1: FStar.Stubs.Reflection.V2.Data.pattern -> p2: FStar.Stubs.Reflection.V2.Data.pattern -> f1: FStar.Stubs.Reflection.Types.fv -> f2: FStar.Stubs.Reflection.Types.fv -> ous1: FStar.Pervasives.Native.option FStar.Stubs.Reflection.V2.Data.universes -> ous2: FStar.Pervasives.Native.option FStar.Stubs.Reflection.V2.Data.universes -> args1: Prims.list (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) -> args2: Prims.list (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) -> FStar.Pervasives.Lemma (requires p1 == FStar.Stubs.Reflection.V2.Data.Pat_Cons f1 ous1 args1 /\ p2 == FStar.Stubs.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))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Stubs.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Stubs.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.Stubs.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.Stubs.Reflection.V2.Data.Pat_Cons", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
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))
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_branch
val faithful_branch (b: branch) : Type0
val faithful_branch (b: branch) : 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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
b: FStar.Stubs.Reflection.V2.Data.branch -> Type0
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.branch", "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Stubs.Reflection.Types.term", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful_pattern", "FStar.Reflection.V2.TermEq.faithful" ]
[ "mutual recursion" ]
false
false
false
true
true
let rec faithful_branch (b: branch) : Type0 =
let p, t = b in faithful_pattern p /\ faithful t
false
FStar.LexicographicOrdering.fst
FStar.LexicographicOrdering.closure_transitive
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)]
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)] = assert (closure r_a y z)
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 33, "start_col": 0, "start_line": 26 }
(* 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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)]
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_pattern
val faithful_pattern (p: pattern) : Type0
val faithful_pattern (p: pattern) : 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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
p: FStar.Stubs.Reflection.V2.Data.pattern -> Type0
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Stubs.Reflection.V2.Data.vconst", "Prims.l_True", "FStar.Stubs.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V2.Data.universes", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Prims.l_and", "FStar.Reflection.V2.TermEq.optP", "FStar.Reflection.V2.TermEq.allP", "FStar.Stubs.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.faithful_univ", "FStar.Reflection.V2.TermEq.faithful_pattern_arg", "FStar.Sealed.sealed", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.ppname_t", "FStar.Reflection.V2.TermEq.faithful" ]
[ "mutual recursion" ]
false
false
false
true
true
let rec 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 | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.term_eq
val term_eq (t1 t2: term) : (b: bool{b ==> t1 == t2})
val term_eq (t1 t2: term) : (b: bool{b ==> t1 == t2})
let term_eq (t1 t2 : term) : (b:bool{b ==> t1 == t2}) = Eq? (term_cmp t1 t2)
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 820, "start_col": 0, "start_line": 819 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> b: Prims.bool{b ==> t1 == t2}
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.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" ]
[]
false
false
false
false
false
let term_eq (t1 t2: term) : (b: bool{b ==> t1 == t2}) =
Eq? (term_cmp t1 t2)
false
FStar.LexicographicOrdering.fst
FStar.LexicographicOrdering.lex_t_wf
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)
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 = fun (| x, y |) -> AccIntro (lex_t_wf_aux x (wf_a x) wf_b y (wf_b x y))
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 72, "end_line": 96, "start_col": 0, "start_line": 95 }
(* 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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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))
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_qual
val faithful_qual (q: aqualv) : Type0
val faithful_qual (q: aqualv) : 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
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 547, "start_col": 0, "start_line": 456 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.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" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "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" }
false
q: FStar.Stubs.Reflection.V2.Data.aqualv -> Type0
Prims.Tot
[ "total" ]
[ "faithful", "faithful_arg", "faithful_qual", "faithful_binder", "faithful_branch", "faithful_pattern", "faithful_pattern_arg", "faithful_attrs", "faithful_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.aqualv", "Prims.l_True", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.TermEq.faithful" ]
[ "mutual recursion" ]
false
false
false
true
true
let rec faithful_qual (q: aqualv) : Type0 =
match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m
false