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
LList.Invariant.fst
LList.Invariant.data
val data (c:cell 'a) : 'a
val data (c:cell 'a) : 'a
let data (c:cell 'a) : 'a = c.data
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 34, "end_line": 36, "start_col": 0, "start_line": 36 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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: LList.Invariant.cell 'a -> 'a
Prims.Tot
[ "total" ]
[]
[ "LList.Invariant.cell", "LList.Invariant.__proj__Mkcell__item__data" ]
[]
false
false
false
true
false
let data (c: cell 'a) : 'a =
c.data
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem64_full
val low_lemma_store_mem64_full (b:buffer64) (i:nat) (v:nat64) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf64 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let h' = buffer_write b i v h in let ptr = buffer_addr b h + scale8 i in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ is_full_update vfh h' hid (S.update_heap64 ptr v (heap_get (coerce vfh))) (S.update_n ptr 8 (heap_taint (coerce vfh)) t) ))
val low_lemma_store_mem64_full (b:buffer64) (i:nat) (v:nat64) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf64 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let h' = buffer_write b i v h in let ptr = buffer_addr b h + scale8 i in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ is_full_update vfh h' hid (S.update_heap64 ptr v (heap_get (coerce vfh))) (S.update_n ptr 8 (heap_taint (coerce vfh)) t) ))
let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 722, "start_col": 0, "start_line": 707 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer64 -> i: Prims.nat -> v: Vale.Def.Words_s.nat64 -> vfh: Vale.Arch.HeapImpl.vale_full_heap -> t: Vale.Arch.HeapTypes_s.taint -> hid: Vale.Arch.HeapImpl.heaplet_id -> FStar.Pervasives.Lemma (requires (let _ = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid, Mkvale_heap_layout?.vl_taint (Mkvale_full_heap?.vf_layout vfh) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ h mt = _ in i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b /\ Vale.X64.Memory.valid_layout_buffer b (Mkvale_full_heap?.vf_layout vfh) h true /\ Vale.X64.Memory.valid_taint_buf64 b h mt t /\ Vale.X64.Memory.mem_inv vfh) <: Type0)) (ensures (let h = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid in let h' = Vale.X64.Memory.buffer_write b i v h in let ptr = Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale8 i in Vale.X64.Memory.buffer_addr b (Mkvale_full_heap?.vf_heap vfh) == Vale.X64.Memory.buffer_addr b h /\ Vale.Arch.MachineHeap_s.valid_addr64 ptr (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh)) /\ Vale.X64.Memory_Sems.is_full_update vfh h' hid (Vale.Arch.MachineHeap_s.update_heap64 ptr v (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh))) (Vale.X64.Machine_Semantics_s.update_n ptr 8 (Vale.Arch.Heap.heap_taint (Vale.X64.Memory_Sems.coerce vfh)) t)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer64", "Prims.nat", "Vale.Def.Words_s.nat64", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.HeapImpl.heaplet_id", "Vale.Arch.HeapImpl.vale_heap", "Vale.X64.Memory.memtaint", "Prims.unit", "Vale.X64.Memory_Sems.lemma_is_full_update", "Vale.Arch.HeapImpl.__proj__ValeHeap__item__mh", "Vale.Arch.HeapTypes_s.TUInt64", "Vale.Arch.MachineHeap.same_mem_get_heap_val64", "Vale.X64.Memory_Sems.in_bounds64", "Vale.Arch.MachineHeap.frame_update_heap64", "Vale.X64.Memory_Sems.low_lemma_store_mem64", "Vale.Lib.Map16.get", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "FStar.Pervasives.reveal_opaque", "Vale.Arch.HeapTypes_s.base_typ", "Vale.X64.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "FStar.Pervasives.Native.option", "Prims.bool", "Vale.Def.Prop_s.prop0", "Vale.X64.Memory.valid_layout_buffer_id", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.update_heap64", "Vale.X64.Memory_Sems.get_heap", "Vale.X64.Memory.buffer_write", "Vale.X64.Memory.vuint64", "Vale.Arch.HeapTypes_s.memTaint_t", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "Prims.eq2", "FStar.Map.sel", "Prims.l_or", "Vale.Arch.Heap.heap_taint", "Vale.X64.Machine_Semantics_s.update_n", "Vale.X64.Memory_Sems.coerce", "Vale.Arch.Heap.heap_impl", "Vale.Arch.Heap.heap_get", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.scale8", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout" ]
[]
false
false
true
false
false
let low_lemma_store_mem64_full b i v vfh t hid =
let h, mt, hk = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; ()
false
LList.Invariant.fst
LList.Invariant.next
val next (c:cell 'a) : t 'a
val next (c:cell 'a) : t 'a
let next (c:cell 'a) : t 'a = c.next
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 36, "end_line": 35, "start_col": 0, "start_line": 35 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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: LList.Invariant.cell 'a -> LList.Invariant.t 'a
Prims.Tot
[ "total" ]
[]
[ "LList.Invariant.cell", "LList.Invariant.__proj__Mkcell__item__next", "LList.Invariant.t" ]
[]
false
false
false
true
false
let next (c: cell 'a) : t 'a =
c.next
false
LList.Invariant.fst
LList.Invariant.hd
val hd : l: _: Prims.list _ {Cons? _} -> _
let hd l = Cons?.hd l
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 41, "start_col": 0, "start_line": 41 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
l: _: Prims.list _ {Cons? _} -> _
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Prims.b2t", "Prims.uu___is_Cons", "Prims.__proj__Cons__item__hd" ]
[]
false
false
false
false
false
let hd l =
Cons?.hd l
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.store_buffer_aux_down128_mem2
val store_buffer_aux_down128_mem2 (ptr: int) (v: quad32) (h: vale_heap{writeable_mem128 ptr h}) : Lemma (ensures (let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr + 4) mem2) (S.get_heap_val32 (ptr + 8) mem2) (S.get_heap_val32 (ptr + 12) mem2) == v))
val store_buffer_aux_down128_mem2 (ptr: int) (v: quad32) (h: vale_heap{writeable_mem128 ptr h}) : Lemma (ensures (let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr + 4) mem2) (S.get_heap_val32 (ptr + 8) mem2) (S.get_heap_val32 (ptr + 12) mem2) == v))
let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 950, "start_col": 0, "start_line": 931 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> v: Vale.X64.Memory.quad32 -> h: Vale.Arch.HeapImpl.vale_heap{Vale.X64.Memory.writeable_mem128 ptr h} -> FStar.Pervasives.Lemma (ensures (let h1 = Vale.X64.Memory.store_mem Vale.Arch.HeapTypes_s.TUInt128 ptr v h in let mem2 = Vale.Interop.down_mem (Vale.Arch.HeapImpl._ih h1) in Vale.Def.Words_s.Mkfour (Vale.Arch.MachineHeap_s.get_heap_val32 ptr mem2) (Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 4) mem2) (Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 8) mem2) (Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 12) mem2) == v))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.X64.Memory.quad32", "Vale.Arch.HeapImpl.vale_heap", "Prims.b2t", "Vale.X64.Memory.writeable_mem128", "Vale.X64.Memory.index128_get_heap_val128", "Prims.unit", "Prims._assert", "Prims.eq2", "Vale.X64.Memory.base_typ_as_vale_type", "FStar.Seq.Base.index", "Vale.X64.Memory.buffer_as_seq", "Vale.X64.Memory.store_buffer_write", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.correct_down", "Vale.Arch.HeapImpl._ih", "Vale.Interop.down_mem", "Vale.X64.Memory.store_mem", "Prims.nat", "Vale.X64.Memory.get_addr_in_ptr", "Vale.X64.Memory.buffer_length", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.length_t_eq", "Vale.Arch.HeapImpl.buffer", "FStar.Pervasives.Native.__proj__Some__item__v", "Vale.X64.Memory.buffer", "Vale.X64.Memory.find_writeable_buffer", "Vale.Arch.HeapTypes_s.base_typ", "Vale.Arch.HeapTypes_s.TUInt128", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.Mkfour", "Vale.Arch.MachineHeap_s.get_heap_val32", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let store_buffer_aux_down128_mem2 (ptr: int) (v: quad32) (h: vale_heap{writeable_mem128 ptr h}) : Lemma (ensures (let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr + 4) mem2) (S.get_heap_val32 (ptr + 8) mem2) (S.get_heap_val32 (ptr + 12) mem2) == v)) =
let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.update_heap128_lo
val update_heap128_lo (ptr: int) (v: quad32) (mem: S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr + 8) mem /\ v.hi3 == S.get_heap_val32 (ptr + 12) mem) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr + 4) v.lo1 (S.update_heap32 ptr v.lo0 mem))
val update_heap128_lo (ptr: int) (v: quad32) (mem: S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr + 8) mem /\ v.hi3 == S.get_heap_val32 (ptr + 12) mem) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr + 4) v.lo1 (S.update_heap32 ptr v.lo0 mem))
let update_heap128_lo (ptr:int) (v:quad32) (mem:S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr+8) mem /\ v.hi3 == S.get_heap_val32 (ptr+12) mem ) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr+4) v.lo1 (S.update_heap32 ptr v.lo0 mem)) = reveal_opaque (`%S.valid_addr128) S.valid_addr128; S.update_heap128_reveal (); let mem0 = S.update_heap32 ptr v.lo0 mem in let mem1 = S.update_heap32 (ptr+4) v.lo1 mem0 in Vale.Arch.MachineHeap.frame_update_heap32 ptr v.lo0 mem; Vale.Arch.MachineHeap.frame_update_heap32 (ptr+4) v.lo1 mem0; Vale.Arch.MachineHeap.same_domain_update32 ptr v.lo0 mem; Vale.Arch.MachineHeap.same_domain_update32 (ptr+4) v.lo1 mem0; frame_get_heap32 (ptr+8) mem mem1; frame_get_heap32 (ptr+12) mem mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+8) mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+12) mem1
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 1066, "start_col": 0, "start_line": 1047 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () //let same_domain_update128_64 b i v h = // low_lemma_valid_mem128_64 b i (_ih h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i) v (get_heap h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i + 8) v (get_heap h) open Vale.Def.Types_s let frame_get_heap32 (ptr:int) (mem1 mem2:S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[i] == mem2.[i])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) = S.get_heap_val32_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> v: Vale.Def.Types_s.quad32 -> mem: Vale.Arch.MachineHeap_s.machine_heap -> FStar.Pervasives.Lemma (requires Vale.Arch.MachineHeap_s.valid_addr128 ptr mem /\ Mkfour?.hi2 v == Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 8) mem /\ Mkfour?.hi3 v == Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 12) mem) (ensures Vale.Arch.MachineHeap_s.update_heap128 ptr v mem == Vale.Arch.MachineHeap_s.update_heap32 (ptr + 4) (Mkfour?.lo1 v) (Vale.Arch.MachineHeap_s.update_heap32 ptr (Mkfour?.lo0 v) mem))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.Def.Types_s.quad32", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap.update_heap32_get_heap32", "Prims.op_Addition", "Prims.unit", "Vale.X64.Memory_Sems.frame_get_heap32", "Vale.Arch.MachineHeap.same_domain_update32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Arch.MachineHeap.frame_update_heap32", "Vale.Arch.MachineHeap_s.update_heap32", "Vale.Arch.MachineHeap_s.update_heap128_reveal", "FStar.Pervasives.reveal_opaque", "Prims.bool", "Vale.Arch.MachineHeap_s.valid_addr128", "Prims.l_and", "Prims.b2t", "Prims.eq2", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Arch.MachineHeap_s.get_heap_val32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.squash", "Vale.Arch.MachineHeap_s.update_heap128", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let update_heap128_lo (ptr: int) (v: quad32) (mem: S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr + 8) mem /\ v.hi3 == S.get_heap_val32 (ptr + 12) mem) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr + 4) v.lo1 (S.update_heap32 ptr v.lo0 mem)) =
reveal_opaque (`%S.valid_addr128) S.valid_addr128; S.update_heap128_reveal (); let mem0 = S.update_heap32 ptr v.lo0 mem in let mem1 = S.update_heap32 (ptr + 4) v.lo1 mem0 in Vale.Arch.MachineHeap.frame_update_heap32 ptr v.lo0 mem; Vale.Arch.MachineHeap.frame_update_heap32 (ptr + 4) v.lo1 mem0; Vale.Arch.MachineHeap.same_domain_update32 ptr v.lo0 mem; Vale.Arch.MachineHeap.same_domain_update32 (ptr + 4) v.lo1 mem0; frame_get_heap32 (ptr + 8) mem mem1; frame_get_heap32 (ptr + 12) mem mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr + 8) mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr + 12) mem1
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.store_buffer_aux_down128_mem
val store_buffer_aux_down128_mem (ptr: int) (v: quad32) (h: vale_heap{writeable_mem128 ptr h}) : Lemma (ensures (let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[ j ]\/mem2.[ j ]} j < ptr \/ j >= ptr + 16 ==> mem1.[ j ] == mem2.[ j ]))
val store_buffer_aux_down128_mem (ptr: int) (v: quad32) (h: vale_heap{writeable_mem128 ptr h}) : Lemma (ensures (let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[ j ]\/mem2.[ j ]} j < ptr \/ j >= ptr + 16 ==> mem1.[ j ] == mem2.[ j ]))
let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 929, "start_col": 0, "start_line": 912 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> v: Vale.X64.Memory.quad32 -> h: Vale.Arch.HeapImpl.vale_heap{Vale.X64.Memory.writeable_mem128 ptr h} -> FStar.Pervasives.Lemma (ensures (let mem1 = Vale.Interop.down_mem (Vale.Arch.HeapImpl._ih h) in let h1 = Vale.X64.Memory.store_mem Vale.Arch.HeapTypes_s.TUInt128 ptr v h in let mem2 = Vale.Interop.down_mem (Vale.Arch.HeapImpl._ih h1) in forall (j: Prims.int). {:pattern mem1.[ j ]\/mem2.[ j ]} j < ptr \/ j >= ptr + 16 ==> mem1.[ j ] == mem2.[ j ]))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.X64.Memory.quad32", "Vale.Arch.HeapImpl.vale_heap", "Prims.b2t", "Vale.X64.Memory.writeable_mem128", "Vale.X64.Memory_Sems.store_buffer_down128_mem", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.op_Addition", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.scale16", "Vale.X64.Memory.store_buffer_write", "Prims.nat", "Vale.X64.Memory.get_addr_in_ptr", "Vale.X64.Memory.buffer_length", "Vale.X64.Memory.length_t_eq", "Vale.Arch.HeapImpl.buffer", "FStar.Pervasives.Native.__proj__Some__item__v", "Vale.X64.Memory.buffer", "Vale.X64.Memory.find_writeable_buffer", "Vale.X64.Memory.store_mem", "Vale.Arch.HeapTypes_s.base_typ", "Vale.Arch.HeapTypes_s.TUInt128", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.l_or", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "Vale.Def.Types_s.nat8", "Vale.X64.Memory.op_String_Access", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.correct_down", "Vale.Arch.HeapImpl._ih", "Vale.Interop.down_mem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let store_buffer_aux_down128_mem (ptr: int) (v: quad32) (h: vale_heap{writeable_mem128 ptr h}) : Lemma (ensures (let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[ j ]\/mem2.[ j ]} j < ptr \/ j >= ptr + 16 ==> mem1.[ j ] == mem2.[ j ])) =
let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i + 1) == ptr + 16); store_buffer_down128_mem b i v h
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.frame_get_heap32
val frame_get_heap32 (ptr: int) (mem1 mem2: S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[ i ] == mem2.[ i ])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2)
val frame_get_heap32 (ptr: int) (mem1 mem2: S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[ i ] == mem2.[ i ])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2)
let frame_get_heap32 (ptr:int) (mem1 mem2:S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[i] == mem2.[i])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) = S.get_heap_val32_reveal ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 1045, "start_col": 0, "start_line": 1042 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () //let same_domain_update128_64 b i v h = // low_lemma_valid_mem128_64 b i (_ih h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i) v (get_heap h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i + 8) v (get_heap h) open Vale.Def.Types_s
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> mem1: Vale.Arch.MachineHeap_s.machine_heap -> mem2: Vale.Arch.MachineHeap_s.machine_heap -> FStar.Pervasives.Lemma (requires forall (i: Prims.int). i >= ptr /\ i < ptr + 4 ==> mem1.[ i ] == mem2.[ i ]) (ensures Vale.Arch.MachineHeap_s.get_heap_val32 ptr mem1 == Vale.Arch.MachineHeap_s.get_heap_val32 ptr mem2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.get_heap_val32_reveal", "Prims.unit", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.X64.Memory.op_String_Access", "Prims.squash", "Vale.Def.Types_s.nat32", "Vale.Arch.MachineHeap_s.get_heap_val32", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let frame_get_heap32 (ptr: int) (mem1 mem2: S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[ i ] == mem2.[ i ])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) =
S.get_heap_val32_reveal ()
false
LList.Invariant.fst
LList.Invariant.tl
val tl : l: _: Prims.list _ {Cons? _} -> Prims.list _
let tl l = Cons?.tl l
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 42, "start_col": 0, "start_line": 42 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d }
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
l: _: Prims.list _ {Cons? _} -> Prims.list _
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Prims.b2t", "Prims.uu___is_Cons", "Prims.__proj__Cons__item__tl" ]
[]
false
false
false
false
false
let tl l =
Cons?.tl l
false
LList.Invariant.fst
LList.Invariant.null_llist
val null_llist (#a:Type) : t a
val null_llist (#a:Type) : t a
let null_llist (#a:Type) = null
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 32, "end_line": 44, "start_col": 0, "start_line": 44 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d } let hd l = Cons?.hd l let tl l = Cons?.tl l
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
LList.Invariant.t a
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.null", "LList.Invariant.cell", "LList.Invariant.t" ]
[]
false
false
false
true
false
let null_llist (#a: Type) =
null
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.written_buffer_down128_aux2
val written_buffer_down128_aux2 (b: buffer128{buffer_writeable b}) (i: nat{i < buffer_length b}) (v: quad32) (h: vale_heap{List.memP b (_ih h).IB.ptrs}) (base: nat{base == buffer_addr b h}) (n: nat{n == buffer_length b}) (k: nat{k > i}) (h1: vale_heap{h1 == buffer_write b i v h}) (mem1: S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2: S.machine_heap { IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[ j ])\/(mem2.[ j ])} base + scale16 (i + 1) <= j /\ j < base + k * 16 ==> mem1.[ j ] == mem2.[ j ]) }) : Lemma (ensures (forall j. {:pattern (mem1.[ j ])\/(mem2.[ j ])} j >= base + scale16 (i + 1) /\ j < base + scale16 n ==> mem1.[ j ] == mem2.[ j ])) (decreases %[n - k])
val written_buffer_down128_aux2 (b: buffer128{buffer_writeable b}) (i: nat{i < buffer_length b}) (v: quad32) (h: vale_heap{List.memP b (_ih h).IB.ptrs}) (base: nat{base == buffer_addr b h}) (n: nat{n == buffer_length b}) (k: nat{k > i}) (h1: vale_heap{h1 == buffer_write b i v h}) (mem1: S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2: S.machine_heap { IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[ j ])\/(mem2.[ j ])} base + scale16 (i + 1) <= j /\ j < base + k * 16 ==> mem1.[ j ] == mem2.[ j ]) }) : Lemma (ensures (forall j. {:pattern (mem1.[ j ])\/(mem2.[ j ])} j >= base + scale16 (i + 1) /\ j < base + scale16 n ==> mem1.[ j ] == mem2.[ j ])) (decreases %[n - k])
let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 854, "start_col": 0, "start_line": 830 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128{Vale.X64.Memory.buffer_writeable b} -> i: Prims.nat{i < Vale.X64.Memory.buffer_length b} -> v: Vale.X64.Memory.quad32 -> h: Vale.Arch.HeapImpl.vale_heap {FStar.List.Tot.Base.memP b (InteropHeap?.ptrs (Vale.Arch.HeapImpl._ih h))} -> base: Prims.nat{base == Vale.X64.Memory.buffer_addr b h} -> n: Prims.nat{n == Vale.X64.Memory.buffer_length b} -> k: Prims.nat{k > i} -> h1: Vale.Arch.HeapImpl.vale_heap{h1 == Vale.X64.Memory.buffer_write b i v h} -> mem1: Vale.Arch.MachineHeap_s.machine_heap {Vale.Interop.Heap_s.correct_down (Vale.Arch.HeapImpl._ih h) mem1} -> mem2: Vale.Arch.MachineHeap_s.machine_heap { Vale.Interop.Heap_s.correct_down (Vale.Arch.HeapImpl._ih h1) mem2 /\ (forall (j: Prims.int). {:pattern mem1.[ j ]\/mem2.[ j ]} base + Vale.X64.Memory.scale16 (i + 1) <= j /\ j < base + k * 16 ==> mem1.[ j ] == mem2.[ j ]) } -> FStar.Pervasives.Lemma (ensures forall (j: Prims.int). {:pattern mem1.[ j ]\/mem2.[ j ]} j >= base + Vale.X64.Memory.scale16 (i + 1) /\ j < base + Vale.X64.Memory.scale16 n ==> mem1.[ j ] == mem2.[ j ]) (decreases n - k)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Vale.X64.Memory.buffer128", "Vale.X64.Memory.buffer_writeable", "Vale.X64.Memory.vuint128", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Vale.X64.Memory.buffer_length", "Vale.X64.Memory.quad32", "Vale.Arch.HeapImpl.vale_heap", "FStar.List.Tot.Base.memP", "Vale.Interop.Types.b8", "Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs", "Vale.Arch.HeapImpl._ih", "Prims.eq2", "Prims.int", "Vale.X64.Memory.buffer_addr", "Prims.op_GreaterThan", "Vale.X64.Memory.buffer_write", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.correct_down", "Prims.l_and", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Vale.X64.Memory.scale16", "FStar.Mul.op_Star", "Vale.Def.Types_s.nat8", "Vale.X64.Memory.op_String_Access", "Prims.op_GreaterThanOrEqual", "Prims.bool", "Vale.X64.Memory_Sems.written_buffer_down128_aux2", "Prims.unit", "Vale.X64.Memory_Sems.heap_shift", "Vale.X64.Memory_Sems.same_mem_get_heap_val128", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec written_buffer_down128_aux2 (b: buffer128{buffer_writeable b}) (i: nat{i < buffer_length b}) (v: quad32) (h: vale_heap{List.memP b (_ih h).IB.ptrs}) (base: nat{base == buffer_addr b h}) (n: nat{n == buffer_length b}) (k: nat{k > i}) (h1: vale_heap{h1 == buffer_write b i v h}) (mem1: S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2: S.machine_heap { IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[ j ])\/(mem2.[ j ])} base + scale16 (i + 1) <= j /\ j < base + k * 16 ==> mem1.[ j ] == mem2.[ j ]) }) : Lemma (ensures (forall j. {:pattern (mem1.[ j ])\/(mem2.[ j ])} j >= base + scale16 (i + 1) /\ j < base + scale16 n ==> mem1.[ j ] == mem2.[ j ])) (decreases %[n - k]) =
if k >= n then () else let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k + 1) h1 mem1 mem2
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_load_mem128_lo64
val low_lemma_load_mem128_lo64 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val64 (buffer_addr b h + scale16 i) (get_heap h) == lo64 (buffer_read b i h) )
val low_lemma_load_mem128_lo64 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val64 (buffer_addr b h + scale16 i) (get_heap h) == lo64 (buffer_read b i h) )
let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 1026, "start_col": 0, "start_line": 1021 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> h: Vale.Arch.HeapImpl.vale_heap -> FStar.Pervasives.Lemma (requires i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b) (ensures Vale.Arch.MachineHeap_s.get_heap_val64 (Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i) (Vale.X64.Memory_Sems.get_heap h) == Vale.Arch.Types.lo64 (Vale.X64.Memory.buffer_read b i h))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.MachineHeap_s.get_heap_val32_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.get_heap_val64_reveal", "Vale.Arch.MachineHeap_s.get_heap_val128_reveal", "Vale.Arch.Types.lo64_reveal", "Vale.X64.Memory_Sems.low_lemma_load_mem128" ]
[]
true
false
true
false
false
let low_lemma_load_mem128_lo64 b i h =
low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal ()
false
Steel.HigherReference.fst
Steel.HigherReference.read
val read (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun h -> True) (ensures fun _ x _ -> x == Ghost.reveal v)
val read (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun h -> True) (ensures fun _ x _ -> x == Ghost.reveal v)
let read (#a:Type) (#p:perm) (#v:erased a) (r:ref a) = let v1 : erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, p)) in rewrite_slprop (pts_to r p v) (RP.pts_to r v1 `star` pure (perm_ok p)) (fun _ -> ()); elim_pure (perm_ok p); let v2 = RP.read r v1 in rewrite_slprop (RP.pts_to r v1) (pts_to r p v) (fun m -> emp_unit (hp_of (pts_to_raw r p v)); pure_star_interp (hp_of (pts_to_raw r p v)) (perm_ok p) m); assert (compatible pcm_frac v1 v2); let Some (x, _) = v2 in rewrite_slprop (pts_to r p v) (pts_to r p x) (fun _ -> ()); return x
{ "file_name": "lib/steel/Steel.HigherReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 158, "start_col": 0, "start_line": 146 }
(* Copyright 2020 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 Steel.HigherReference open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open FStar.PCM open Steel.PCMFrac open FStar.Real module RP = Steel.PCMReference #set-options "--ide_id_info_off" module Mem = Steel.Memory let ref a = Mem.ref (fractional a) pcm_frac let null #a = Mem.null #(fractional a) #pcm_frac let is_null #a r = Mem.is_null #(fractional a) #pcm_frac r let perm_ok p : prop = (p.v <=. one == true) /\ True let pts_to_raw_sl (#a:Type) (r:ref a) (p:perm) (v:erased a) : slprop = Mem.pts_to r (Some (Ghost.reveal v, p)) let pts_to_raw (#a:Type) (r:ref a) (p:perm) (v:erased a) : vprop = to_vprop (Mem.pts_to r (Some (Ghost.reveal v, p))) [@@__reduce__] let pts_to' (#a:Type u#1) (r:ref a) (p:perm) (v:erased a) : vprop = pts_to_raw r p v `star` pure (perm_ok p) let pts_to_sl #a r p v = hp_of (pts_to' r p v) let abcd_acbd (a b c d:slprop) : Lemma (Mem.(((a `star` b) `star` (c `star` d)) `equiv` ((a `star` c) `star` (b `star` d)))) = let open Steel.Memory in calc (equiv) { ((a `star` b) `star` (c `star` d)); (equiv) { star_associative a b (c `star` d) } ((a `star` (b `star` (c `star` d)))); (equiv) { star_associative b c d; star_congruence a (b `star` (c `star` d)) a ((b `star` c) `star` d) } (a `star` ((b `star` c) `star` d)); (equiv) { star_commutative b c; star_congruence (b `star` c) d (c `star` b) d; star_congruence a ((b `star` c) `star` d) a ((c `star` b) `star` d) } (a `star` ((c `star` b) `star` d)); (equiv) { star_associative c b d; star_congruence a ((c `star` b) `star` d) a (c `star` (b `star` d)) } (a `star` (c `star` (b `star` d))); (equiv) { star_associative a c (b `star` d) } ((a `star` c) `star` (b `star` d)); } let pts_to_ref_injective (#a: Type u#1) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) = let open Steel.Memory in abcd_acbd (hp_of (pts_to_raw r p0 v0)) (pure (perm_ok p0)) (hp_of (pts_to_raw r p1 v1)) (pure (perm_ok p1)); Mem.affine_star (hp_of (pts_to_raw r p0 v0) `star` hp_of (pts_to_raw r p1 v1)) (pure (perm_ok p0) `star` pure (perm_ok p1)) m; Mem.pts_to_compatible r (Some (Ghost.reveal v0, p0)) (Some (Ghost.reveal v1, p1)) m let pts_to_not_null (#a:Type u#1) (r:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures r =!= null) = Mem.affine_star (hp_of (pts_to_raw r p v)) (Mem.pure (perm_ok p)) m; Mem.pts_to_not_null r (Some (Ghost.reveal v, p)) m let pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) = let aux (x y : erased a) (m:mem) : Lemma (requires (interp (pts_to_sl r p x) m /\ interp (pts_to_sl r p y) m)) (ensures (x == y)) = Mem.pts_to_join r (Some (Ghost.reveal x, p)) (Some (Ghost.reveal y, p)) m in Classical.forall_intro_3 (fun x y -> Classical.move_requires (aux x y)) let higher_ref_pts_to_injective_eq #a #opened #p0 #p1 #v0 #v1 r = extract_info_raw (pts_to r p0 v0 `star` pts_to r p1 v1) (v0 == v1) (fun m -> pts_to_ref_injective r p0 p1 v0 v1 m); rewrite_slprop (pts_to r p1 v1) (pts_to r p1 v0) (fun _ -> ()) let pts_to_framon (#a:Type) (r:ref a) (p:perm) : Lemma (is_frame_monotonic (pts_to_sl r p)) = pts_to_witinv r p let intro_pts_to (p:perm) #a #uses (#v:erased a) (r:ref a) : SteelGhost unit uses (pts_to_raw r p v) (fun _ -> pts_to r p v) (requires fun _ -> perm_ok p) (ensures fun _ _ _ -> True) = intro_pure (perm_ok p); rewrite_slprop (pts_to' r p v) (pts_to r p v) (fun _ -> ()) let pts_to_perm #_ #_ #p #v r = rewrite_slprop (pts_to r p v) (pts_to' r p v) (fun _ -> ()); elim_pure (perm_ok p); intro_pure (perm_ok p); rewrite_slprop (pts_to' r p v) (pts_to r p v) (fun _ -> ()) let alloc #a x = let v = Some (x, full_perm) in assert (FStar.PCM.composable pcm_frac v None); assert (compatible pcm_frac v v); let r = RP.alloc v in rewrite_slprop (RP.pts_to r v) (pts_to r full_perm x) (fun m -> emp_unit (hp_of (pts_to_raw r full_perm x)); pure_star_interp (hp_of (pts_to_raw r full_perm x)) (perm_ok full_perm) m ); extract_info_raw (pts_to r full_perm x) (~ (is_null r)) (fun m -> pts_to_not_null r full_perm x m); return r
{ "checked_file": "/", "dependencies": [ "Steel.PCMReference.fsti.checked", "Steel.PCMFrac.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.NMSTTotal.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Steel.HigherReference.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "RP" }, { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": false, "full_module": "Steel.PCMFrac", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": 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: Steel.HigherReference.ref a -> Steel.Effect.Steel a
Steel.Effect.Steel
[]
[]
[ "Steel.FractionalPermission.perm", "FStar.Ghost.erased", "Steel.HigherReference.ref", "Steel.Effect.Atomic.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.HigherReference.pts_to", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.reveal", "Steel.Memory.mem", "Steel.PCMFrac.fractional", "Prims._assert", "FStar.PCM.compatible", "Steel.PCMFrac.pcm_frac", "Steel.PCMReference.pts_to", "Steel.Memory.pure_star_interp", "Steel.Effect.Common.hp_of", "Steel.HigherReference.pts_to_raw", "Steel.HigherReference.perm_ok", "Steel.Memory.emp_unit", "Steel.PCMReference.read", "Steel.Effect.Atomic.elim_pure", "Steel.Effect.Common.star", "Steel.Effect.Common.pure", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2" ]
[]
false
true
false
false
false
let read (#a: Type) (#p: perm) (#v: erased a) (r: ref a) =
let v1:erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, p)) in rewrite_slprop (pts_to r p v) ((RP.pts_to r v1) `star` (pure (perm_ok p))) (fun _ -> ()); elim_pure (perm_ok p); let v2 = RP.read r v1 in rewrite_slprop (RP.pts_to r v1) (pts_to r p v) (fun m -> emp_unit (hp_of (pts_to_raw r p v)); pure_star_interp (hp_of (pts_to_raw r p v)) (perm_ok p) m); assert (compatible pcm_frac v1 v2); let Some (x, _) = v2 in rewrite_slprop (pts_to r p v) (pts_to r p x) (fun _ -> ()); return x
false
LowStar.Literal.fsti
LowStar.Literal.u8s_of_ascii_string
val u8s_of_ascii_string (s: ascii_string) : ss: Seq.seq UInt8.t {Seq.length ss = List.Tot.length (String.list_of_string s)}
val u8s_of_ascii_string (s: ascii_string) : ss: Seq.seq UInt8.t {Seq.length ss = List.Tot.length (String.list_of_string s)}
let u8s_of_ascii_string (s: ascii_string): ss:Seq.seq UInt8.t { Seq.length ss = List.Tot.length (String.list_of_string s) } = let cs = List.Tot.map u8_of_ascii_char (ascii_chars_of_ascii_string s) in Seq.seq_of_list cs
{ "file_name": "ulib/LowStar.Literal.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 71, "start_col": 0, "start_line": 67 }
module LowStar.Literal module B = LowStar.Buffer module IB = LowStar.ImmutableBuffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST open FStar.Mul /// This module enables clients to make use of string literals in Low* as /// shorthand syntax for immutable, always-live uint8 buffers. See /// LowStar.printf for writing and printing string literals. /// .. note:: /// /// This module supersedes ``C.String``. /// As a reminder, the F* compiler enforces that string literals are UTF-8 /// encoded, and list_of_string returns the corresponding sequence of Unicode /// scalar values (see https://erratique.ch/software/uucp/doc/Uucp.html#uminimal) for an excellent /// crash course on Unicode. /// When compiling with KaRaMeL, string literals are printed as series of bytes, /// where non-alphanumeric characters are hex-encoded. For instance, if after reading /// the C standard, the user writes ``let x = "🤮"``, then KaRaMeL will generate /// ``const char *x = "\xf0\x9f\xa4\xae"``. /// String literals as buffers /// -------------------------- /// Therefore, in order to talk about the interpretation of a string literal as /// a series of bytes, we need to define the serialization of Unicode scalar values /// (as returned by ``String.list_of_string``) into bytes. This is a commendable and /// noble goal, but instead, we choose to restrict ourselves to the ASCII subset of /// UTF-8, where the byte encoding of a scalar value is the identity. let is_ascii_char (c: Char.char) = UInt32.lt (Char.u32_of_char c) 0x80ul let ascii_char = c:Char.char{is_ascii_char c} let is_ascii_string (s: string) = List.Tot.for_all is_ascii_char (String.list_of_string s) let ascii_string = s:string{is_ascii_string s} let for_all_tail #a p (l: list a { Cons? l }): Lemma (requires (List.Tot.for_all p l)) (ensures (List.Tot.for_all p (List.Tot.tl l))) = () let ascii_chars_of_ascii_string (s: ascii_string): l:list ascii_char { List.Tot.length l = String.length s } = List.Tot.list_refb #(Char.char) #_ (String.list_of_string s) let u8_of_ascii_char (c: ascii_char): x:UInt8.t{ UInt8.v x = Char.int_of_char c } = let x32 = Char.u32_of_char c in assert_norm (pow2 24 * pow2 8 = pow2 32); Math.Lemmas.modulo_modulo_lemma (UInt32.v x32) (pow2 24) (pow2 8); Int.Cast.Full.uint32_to_uint8 x32 /// This means that if a string literal only contains ASCII, then we can easily /// reflect its contents in terms of uint8's, without having to talk about the utf8 /// encoding. /// TODO: lemma: S.index (u8s_of_string s) i = String.index s i /// (cannot be proven right now because we don't know much about String.index)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int.Cast.Full.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Literal.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": 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
s: LowStar.Literal.ascii_string -> ss: FStar.Seq.Base.seq FStar.UInt8.t {FStar.Seq.Base.length ss = FStar.List.Tot.Base.length (FStar.String.list_of_string s)}
Prims.Tot
[ "total" ]
[]
[ "LowStar.Literal.ascii_string", "FStar.Seq.Base.seq_of_list", "FStar.UInt8.t", "Prims.list", "FStar.List.Tot.Base.map", "LowStar.Literal.ascii_char", "LowStar.Literal.u8_of_ascii_char", "LowStar.Literal.ascii_chars_of_ascii_string", "FStar.Seq.Base.seq", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "FStar.List.Tot.Base.length", "FStar.String.char", "FStar.String.list_of_string" ]
[]
false
false
false
false
false
let u8s_of_ascii_string (s: ascii_string) : ss: Seq.seq UInt8.t {Seq.length ss = List.Tot.length (String.list_of_string s)} =
let cs = List.Tot.map u8_of_ascii_char (ascii_chars_of_ascii_string s) in Seq.seq_of_list cs
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.lemma_is_full_update
val lemma_is_full_update (vfh: vale_full_heap) (h hk hk': vale_heap) (k: heaplet_id) (mh mh' mhk mhk': machine_heap) (mt mt': memtaint) (t: base_typ) (b: buffer t) (ptr: int) (v_size index: nat) (v: base_typ_as_vale_type t) (tn: taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j. {:pattern mh.[ j ]\/mh'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mh.[ j ] == mh'.[ j ]) /\ (forall j. {:pattern mhk.[ j ]\/mhk'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mhk.[ j ] == mhk'.[ j ]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i. {:pattern mh'.[ i ]\/mhk'.[ i ]} i >= ptr /\ i < ptr + v_size ==> mh'.[ i ] == mhk'.[ i ]) /\ True) (ensures is_full_update vfh hk' k mh' mt')
val lemma_is_full_update (vfh: vale_full_heap) (h hk hk': vale_heap) (k: heaplet_id) (mh mh' mhk mhk': machine_heap) (mt mt': memtaint) (t: base_typ) (b: buffer t) (ptr: int) (v_size index: nat) (v: base_typ_as_vale_type t) (tn: taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j. {:pattern mh.[ j ]\/mh'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mh.[ j ] == mh'.[ j ]) /\ (forall j. {:pattern mhk.[ j ]\/mhk'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mhk.[ j ] == mhk'.[ j ]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i. {:pattern mh'.[ i ]\/mhk'.[ i ]} i >= ptr /\ i < ptr + v_size ==> mh'.[ i ] == mhk'.[ i ]) /\ True) (ensures is_full_update vfh hk' k mh' mt')
let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 705, "start_col": 0, "start_line": 657 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100"
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
vfh: Vale.Arch.HeapImpl.vale_full_heap -> h: Vale.Arch.HeapImpl.vale_heap -> hk: Vale.Arch.HeapImpl.vale_heap -> hk': Vale.Arch.HeapImpl.vale_heap -> k: Vale.Arch.HeapImpl.heaplet_id -> mh: Vale.Arch.MachineHeap_s.machine_heap -> mh': Vale.Arch.MachineHeap_s.machine_heap -> mhk: Vale.Arch.MachineHeap_s.machine_heap -> mhk': Vale.Arch.MachineHeap_s.machine_heap -> mt: Vale.X64.Memory.memtaint -> mt': Vale.X64.Memory.memtaint -> t: Vale.Arch.HeapTypes_s.base_typ -> b: Vale.Arch.HeapImpl.buffer t -> ptr: Prims.int -> v_size: Prims.nat -> index: Prims.nat -> v: Vale.X64.Memory.base_typ_as_vale_type t -> tn: Vale.Arch.HeapTypes_s.taint -> FStar.Pervasives.Lemma (requires Mkvale_heap_layout_inner?.vl_heaplets_initialized (Mkvale_heap_layout?.vl_inner (Mkvale_full_heap?.vf_layout vfh)) /\ Vale.X64.Memory.mem_inv vfh /\ Vale.X64.Memory.buffer_readable hk b /\ Vale.X64.Memory.buffer_writeable b /\ index < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq hk b) /\ mt == Mkvale_heap_layout?.vl_taint (Mkvale_full_heap?.vf_layout vfh) /\ h == Mkvale_full_heap?.vf_heap vfh /\ hk == Vale.Lib.Map16.sel (Mkvale_full_heap?.vf_heaplets vfh) k /\ mh == ValeHeap?.mh h /\ mhk == ValeHeap?.mh hk /\ ptr == Vale.X64.Memory.buffer_addr b hk + Vale.X64.Memory.scale_by v_size index /\ mt' == Vale.X64.Machine_Semantics_s.update_n ptr v_size (Vale.Arch.Heap.heap_taint (Vale.X64.Memory_Sems.coerce vfh)) tn /\ hk' == Vale.X64.Memory.buffer_write b index v hk /\ Vale.X64.Memory.valid_layout_buffer b (Mkvale_full_heap?.vf_layout vfh) hk true /\ Vale.X64.Memory.valid_taint_buf b hk mt tn /\ Vale.Arch.MachineHeap_s.is_machine_heap_update mh mh' /\ Vale.X64.Memory_Sems.upd_heap h mh' == Vale.X64.Memory.buffer_write b index v h /\ Vale.Arch.MachineHeap_s.is_machine_heap_update mhk mhk' /\ Vale.X64.Memory_Sems.upd_heap hk mhk' == Vale.X64.Memory.buffer_write b index v hk /\ (forall (j: Prims.int). {:pattern mh.[ j ]\/mh'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mh.[ j ] == mh'.[ j ]) /\ (forall (j: Prims.int). {:pattern mhk.[ j ]\/mhk'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mhk.[ j ] == mhk'.[ j ]) /\ 0 <= Vale.X64.Memory.scale_by v_size index /\ Vale.X64.Memory.scale_by v_size index + v_size <= LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) /\ (forall (i: Prims.int). {:pattern mh'.[ i ]\/mhk'.[ i ]} i >= ptr /\ i < ptr + v_size ==> mh'.[ i ] == mhk'.[ i ]) /\ Prims.l_True) (ensures Vale.X64.Memory_Sems.is_full_update vfh hk' k mh' mt')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.HeapImpl.heaplet_id", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.X64.Memory.memtaint", "Vale.Arch.HeapTypes_s.base_typ", "Vale.Arch.HeapImpl.buffer", "Prims.int", "Prims.nat", "Vale.X64.Memory.base_typ_as_vale_type", "Vale.Arch.HeapTypes_s.taint", "Prims.unit", "Vale.Interop.Heap_s.list_disjoint_or_eq_reveal", "Prims._assert", "FStar.Map.equal", "Vale.Lib.Map16.equal", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.Lib.Map16.upd", "Prims.l_not", "Prims.eq2", "Prims.squash", "Vale.Lib.Map16.sel", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil", "Vale.Interop.down_up_identity", "FStar.Ghost.reveal", "Vale.Interop.Heap_s.interop_heap", "Vale.Arch.HeapImpl.__proj__ValeHeap__item__ih", "Vale.Def.Types_s.nat8", "Vale.Arch.HeapImpl.__proj__ValeHeap__item__mh", "FStar.Map.t", "Vale.Def.Words_s.nat8", "FStar.Map.concat", "FStar.Map.restrict", "FStar.Set.set", "FStar.Set.intersect", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplet_sets", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_inner", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout", "FStar.Map.domain", "Vale.X64.Memory_Sems.coerce", "Vale.Arch.Heap.heap_impl", "Vale.Arch.Heap.heap_upd", "FStar.Pervasives.reveal_opaque", "Vale.X64.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "FStar.Pervasives.Native.option", "Prims.bool", "Vale.Def.Prop_s.prop0", "Vale.X64.Memory.valid_layout_buffer_id", "Prims.l_and", "Prims.b2t", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplets_initialized", "Vale.X64.Memory.mem_inv", "Vale.X64.Memory.buffer_readable", "Vale.X64.Memory.buffer_writeable", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.X64.Memory.buffer_as_seq", "Vale.Arch.HeapTypes_s.memTaint_t", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Prims.op_Addition", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.scale_by", "Vale.X64.Machine_Semantics_s.update_n", "Vale.Arch.Heap.heap_taint", "Vale.X64.Memory.buffer_write", "Vale.X64.Memory.valid_layout_buffer", "Vale.X64.Memory.valid_taint_buf", "Vale.Arch.MachineHeap_s.is_machine_heap_update", "Vale.X64.Memory_Sems.upd_heap", "Prims.l_Forall", "Prims.l_imp", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Vale.X64.Memory.op_String_Access", "Prims.op_LessThanOrEqual", "LowStar.BufferView.Down.length", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Prims.l_True", "Vale.X64.Memory_Sems.is_full_update" ]
[]
false
false
true
false
false
let lemma_is_full_update (vfh: vale_full_heap) (h hk hk': vale_heap) (k: heaplet_id) (mh mh' mhk mhk': machine_heap) (mt mt': memtaint) (t: base_typ) (b: buffer t) (ptr: int) (v_size index: nat) (v: base_typ_as_vale_type t) (tn: taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j. {:pattern mh.[ j ]\/mh'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mh.[ j ] == mh'.[ j ]) /\ (forall j. {:pattern mhk.[ j ]\/mhk'.[ j ]} j < ptr \/ j >= ptr + v_size ==> mhk.[ j ] == mhk'.[ j ]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i. {:pattern mh'.[ i ]\/mhk'.[ i ]} i >= ptr /\ i < ptr + v_size ==> mh'.[ i ] == mhk'.[ i ]) /\ True) (ensures is_full_update vfh hk' k mh' mt') =
reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j: heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); ()
false
LList.Invariant.fst
LList.Invariant.llist
val llist (#a:Type) (ptr:t a) (l:list (cell a)) : vprop
val llist (#a:Type) (ptr:t a) (l:list (cell a)) : vprop
let llist = llist'
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 18, "end_line": 63, "start_col": 0, "start_line": 63 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d } let hd l = Cons?.hd l let tl l = Cons?.tl l let null_llist (#a:Type) = null let ptr_eq (#a:Type) (x y:t a) = admit() //////////////////////////////////////////////////////////////////////////////// // Main llist invariant //////////////////////////////////////////////////////////////////////////////// let rec llist' (#a:Type) (ptr:t a) (l:list (cell a)) : Tot vprop (decreases l) = match l with | [] -> pure (ptr == null_llist) | hd :: tl -> pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star`
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
ptr: LList.Invariant.t a -> l: Prims.list (LList.Invariant.cell a) -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "LList.Invariant.llist'" ]
[]
false
false
false
true
false
let llist =
llist'
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem64_aux
val low_lemma_store_mem64_aux (b: buffer64) (heap: S.machine_heap) (i: nat{i < buffer_length b}) (v: nat64) (h: vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b)))
val low_lemma_store_mem64_aux (b: buffer64) (heap: S.machine_heap) (i: nat{i < buffer_length b}) (v: nat64) (h: vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b)))
let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs)
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 607, "start_col": 0, "start_line": 588 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer64 -> heap: Vale.Arch.MachineHeap_s.machine_heap -> i: Prims.nat{i < Vale.X64.Memory.buffer_length b} -> v: Vale.Def.Words_s.nat64 -> h: Vale.Arch.HeapImpl.vale_heap {Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b} -> FStar.Pervasives.Lemma (requires Vale.Interop.Heap_s.correct_down_p (Vale.Arch.HeapImpl._ih h) heap b) (ensures (let heap' = Vale.Arch.MachineHeap_s.update_heap64 (Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale8 i) v heap in let h' = Vale.X64.Memory.store_mem64 (Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale8 i) v h in InteropHeap?.hs (Vale.Arch.HeapImpl._ih h') == LowStar.BufferView.Down.upd_seq (InteropHeap?.hs (Vale.Arch.HeapImpl._ih h)) (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) (Vale.Interop.get_seq_heap heap' (InteropHeap?.addrs (Vale.Arch.HeapImpl._ih h)) b)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer64", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Vale.X64.Memory.buffer_length", "Vale.X64.Memory.vuint64", "Vale.Def.Words_s.nat64", "Vale.Arch.HeapImpl.vale_heap", "Prims.l_and", "Vale.X64.Memory.buffer_readable", "Vale.X64.Memory.buffer_writeable", "Prims._assert", "Prims.eq2", "FStar.Monotonic.HyperStack.mem", "LowStar.BufferView.Up.upd", "FStar.UInt64.t", "Vale.Interop.Heap_s.__proj__InteropHeap__item__hs", "Vale.Arch.HeapImpl._ih", "FStar.UInt64.uint_to_t", "LowStar.BufferView.Up.buffer", "LowStar.BufferView.Up.mk_buffer", "FStar.UInt8.t", "Vale.Interop.Views.up_view64", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Prims.unit", "Vale.X64.BufferViewStore.bv_upd_update_heap64", "Vale.X64.Memory.length_t_eq", "Vale.Arch.HeapTypes_s.TUInt64", "Vale.X64.Memory.lemma_store_mem64", "Vale.X64.Memory.store_mem64", "Vale.Arch.MachineHeap_s.update_heap64", "Prims.int", "Prims.op_Addition", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.scale8", "Vale.Interop.Heap_s.correct_down_p", "Prims.squash", "LowStar.BufferView.Down.upd_seq", "Vale.Interop.get_seq_heap", "Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let low_lemma_store_mem64_aux (b: buffer64) (heap: S.machine_heap) (i: nat{i < buffer_length b}) (v: nat64) (h: vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) =
let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs)
false
LowStar.Literal.fsti
LowStar.Literal.buffer_of_literal_post
val buffer_of_literal_post : s: LowStar.Literal.ascii_string -> h0: FStar.Monotonic.HyperStack.mem -> b: LowStar.ImmutableBuffer.ibuffer FStar.UInt8.t -> h1: FStar.Monotonic.HyperStack.mem -> Prims.logical
let buffer_of_literal_post (s: ascii_string) (h0: HS.mem) (b: IB.ibuffer UInt8.t) (h1: HS.mem) = IB.frameOf b == HS.root /\ // is this really useful? IB.recallable b /\ ( // An inlined version of alloc_post_mem_common, without the unused_in // condition, which would contradict the Stack annotation let s = u8s_of_ascii_string s in IB.live h1 b /\ Map.domain (HS.get_hmap h1) `Set.equal` Map.domain (HS.get_hmap h0) /\ HS.get_tip h1 == HS.get_tip h0 /\ B.(modifies loc_none h0 h1) /\ B.as_seq h1 b == s)
{ "file_name": "ulib/LowStar.Literal.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 83, "start_col": 7, "start_line": 73 }
module LowStar.Literal module B = LowStar.Buffer module IB = LowStar.ImmutableBuffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST open FStar.Mul /// This module enables clients to make use of string literals in Low* as /// shorthand syntax for immutable, always-live uint8 buffers. See /// LowStar.printf for writing and printing string literals. /// .. note:: /// /// This module supersedes ``C.String``. /// As a reminder, the F* compiler enforces that string literals are UTF-8 /// encoded, and list_of_string returns the corresponding sequence of Unicode /// scalar values (see https://erratique.ch/software/uucp/doc/Uucp.html#uminimal) for an excellent /// crash course on Unicode. /// When compiling with KaRaMeL, string literals are printed as series of bytes, /// where non-alphanumeric characters are hex-encoded. For instance, if after reading /// the C standard, the user writes ``let x = "🤮"``, then KaRaMeL will generate /// ``const char *x = "\xf0\x9f\xa4\xae"``. /// String literals as buffers /// -------------------------- /// Therefore, in order to talk about the interpretation of a string literal as /// a series of bytes, we need to define the serialization of Unicode scalar values /// (as returned by ``String.list_of_string``) into bytes. This is a commendable and /// noble goal, but instead, we choose to restrict ourselves to the ASCII subset of /// UTF-8, where the byte encoding of a scalar value is the identity. let is_ascii_char (c: Char.char) = UInt32.lt (Char.u32_of_char c) 0x80ul let ascii_char = c:Char.char{is_ascii_char c} let is_ascii_string (s: string) = List.Tot.for_all is_ascii_char (String.list_of_string s) let ascii_string = s:string{is_ascii_string s} let for_all_tail #a p (l: list a { Cons? l }): Lemma (requires (List.Tot.for_all p l)) (ensures (List.Tot.for_all p (List.Tot.tl l))) = () let ascii_chars_of_ascii_string (s: ascii_string): l:list ascii_char { List.Tot.length l = String.length s } = List.Tot.list_refb #(Char.char) #_ (String.list_of_string s) let u8_of_ascii_char (c: ascii_char): x:UInt8.t{ UInt8.v x = Char.int_of_char c } = let x32 = Char.u32_of_char c in assert_norm (pow2 24 * pow2 8 = pow2 32); Math.Lemmas.modulo_modulo_lemma (UInt32.v x32) (pow2 24) (pow2 8); Int.Cast.Full.uint32_to_uint8 x32 /// This means that if a string literal only contains ASCII, then we can easily /// reflect its contents in terms of uint8's, without having to talk about the utf8 /// encoding. /// TODO: lemma: S.index (u8s_of_string s) i = String.index s i /// (cannot be proven right now because we don't know much about String.index) /// (is this even what we want? should we do everything in terms of list_of_string?) let u8s_of_ascii_string (s: ascii_string): ss:Seq.seq UInt8.t { Seq.length ss = List.Tot.length (String.list_of_string s) } = let cs = List.Tot.map u8_of_ascii_char (ascii_chars_of_ascii_string s) in Seq.seq_of_list cs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int.Cast.Full.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Literal.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": 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
s: LowStar.Literal.ascii_string -> h0: FStar.Monotonic.HyperStack.mem -> b: LowStar.ImmutableBuffer.ibuffer FStar.UInt8.t -> h1: FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "LowStar.Literal.ascii_string", "FStar.Monotonic.HyperStack.mem", "LowStar.ImmutableBuffer.ibuffer", "FStar.UInt8.t", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.ImmutableBuffer.immutable_preorder", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.recallable", "LowStar.Monotonic.Buffer.live", "FStar.Set.equal", "FStar.Map.domain", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.get_tip", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "FStar.Seq.Base.seq", "LowStar.Monotonic.Buffer.as_seq", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "FStar.List.Tot.Base.length", "FStar.String.char", "FStar.String.list_of_string", "LowStar.Literal.u8s_of_ascii_string", "Prims.logical" ]
[]
false
false
false
true
true
let buffer_of_literal_post (s: ascii_string) (h0: HS.mem) (b: IB.ibuffer UInt8.t) (h1: HS.mem) =
IB.frameOf b == HS.root /\ IB.recallable b /\ (let s = u8s_of_ascii_string s in IB.live h1 b /\ (Map.domain (HS.get_hmap h1)) `Set.equal` (Map.domain (HS.get_hmap h0)) /\ HS.get_tip h1 == HS.get_tip h0 /\ B.(modifies loc_none h0 h1) /\ B.as_seq h1 b == s)
false
LowStar.Literal.fsti
LowStar.Literal.ascii_chars_of_ascii_string
val ascii_chars_of_ascii_string (s: ascii_string) : l: list ascii_char {List.Tot.length l = String.length s}
val ascii_chars_of_ascii_string (s: ascii_string) : l: list ascii_char {List.Tot.length l = String.length s}
let ascii_chars_of_ascii_string (s: ascii_string): l:list ascii_char { List.Tot.length l = String.length s } = List.Tot.list_refb #(Char.char) #_ (String.list_of_string s)
{ "file_name": "ulib/LowStar.Literal.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 53, "start_col": 0, "start_line": 51 }
module LowStar.Literal module B = LowStar.Buffer module IB = LowStar.ImmutableBuffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST open FStar.Mul /// This module enables clients to make use of string literals in Low* as /// shorthand syntax for immutable, always-live uint8 buffers. See /// LowStar.printf for writing and printing string literals. /// .. note:: /// /// This module supersedes ``C.String``. /// As a reminder, the F* compiler enforces that string literals are UTF-8 /// encoded, and list_of_string returns the corresponding sequence of Unicode /// scalar values (see https://erratique.ch/software/uucp/doc/Uucp.html#uminimal) for an excellent /// crash course on Unicode. /// When compiling with KaRaMeL, string literals are printed as series of bytes, /// where non-alphanumeric characters are hex-encoded. For instance, if after reading /// the C standard, the user writes ``let x = "🤮"``, then KaRaMeL will generate /// ``const char *x = "\xf0\x9f\xa4\xae"``. /// String literals as buffers /// -------------------------- /// Therefore, in order to talk about the interpretation of a string literal as /// a series of bytes, we need to define the serialization of Unicode scalar values /// (as returned by ``String.list_of_string``) into bytes. This is a commendable and /// noble goal, but instead, we choose to restrict ourselves to the ASCII subset of /// UTF-8, where the byte encoding of a scalar value is the identity. let is_ascii_char (c: Char.char) = UInt32.lt (Char.u32_of_char c) 0x80ul let ascii_char = c:Char.char{is_ascii_char c} let is_ascii_string (s: string) = List.Tot.for_all is_ascii_char (String.list_of_string s) let ascii_string = s:string{is_ascii_string s} let for_all_tail #a p (l: list a { Cons? l }): Lemma (requires (List.Tot.for_all p l)) (ensures (List.Tot.for_all p (List.Tot.tl l))) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int.Cast.Full.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Literal.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": 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
s: LowStar.Literal.ascii_string -> l: Prims.list LowStar.Literal.ascii_char {FStar.List.Tot.Base.length l = FStar.String.length s}
Prims.Tot
[ "total" ]
[]
[ "LowStar.Literal.ascii_string", "FStar.List.Tot.Base.list_refb", "FStar.Char.char", "LowStar.Literal.is_ascii_char", "FStar.String.list_of_string", "Prims.list", "LowStar.Literal.ascii_char", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.List.Tot.Base.length", "FStar.String.length" ]
[]
false
false
false
false
false
let ascii_chars_of_ascii_string (s: ascii_string) : l: list ascii_char {List.Tot.length l = String.length s} =
List.Tot.list_refb #(Char.char) #_ (String.list_of_string s)
false
LowStar.Literal.fsti
LowStar.Literal.u8_of_ascii_char
val u8_of_ascii_char (c: ascii_char) : x: UInt8.t{UInt8.v x = Char.int_of_char c}
val u8_of_ascii_char (c: ascii_char) : x: UInt8.t{UInt8.v x = Char.int_of_char c}
let u8_of_ascii_char (c: ascii_char): x:UInt8.t{ UInt8.v x = Char.int_of_char c } = let x32 = Char.u32_of_char c in assert_norm (pow2 24 * pow2 8 = pow2 32); Math.Lemmas.modulo_modulo_lemma (UInt32.v x32) (pow2 24) (pow2 8); Int.Cast.Full.uint32_to_uint8 x32
{ "file_name": "ulib/LowStar.Literal.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 59, "start_col": 0, "start_line": 55 }
module LowStar.Literal module B = LowStar.Buffer module IB = LowStar.ImmutableBuffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST open FStar.Mul /// This module enables clients to make use of string literals in Low* as /// shorthand syntax for immutable, always-live uint8 buffers. See /// LowStar.printf for writing and printing string literals. /// .. note:: /// /// This module supersedes ``C.String``. /// As a reminder, the F* compiler enforces that string literals are UTF-8 /// encoded, and list_of_string returns the corresponding sequence of Unicode /// scalar values (see https://erratique.ch/software/uucp/doc/Uucp.html#uminimal) for an excellent /// crash course on Unicode. /// When compiling with KaRaMeL, string literals are printed as series of bytes, /// where non-alphanumeric characters are hex-encoded. For instance, if after reading /// the C standard, the user writes ``let x = "🤮"``, then KaRaMeL will generate /// ``const char *x = "\xf0\x9f\xa4\xae"``. /// String literals as buffers /// -------------------------- /// Therefore, in order to talk about the interpretation of a string literal as /// a series of bytes, we need to define the serialization of Unicode scalar values /// (as returned by ``String.list_of_string``) into bytes. This is a commendable and /// noble goal, but instead, we choose to restrict ourselves to the ASCII subset of /// UTF-8, where the byte encoding of a scalar value is the identity. let is_ascii_char (c: Char.char) = UInt32.lt (Char.u32_of_char c) 0x80ul let ascii_char = c:Char.char{is_ascii_char c} let is_ascii_string (s: string) = List.Tot.for_all is_ascii_char (String.list_of_string s) let ascii_string = s:string{is_ascii_string s} let for_all_tail #a p (l: list a { Cons? l }): Lemma (requires (List.Tot.for_all p l)) (ensures (List.Tot.for_all p (List.Tot.tl l))) = () let ascii_chars_of_ascii_string (s: ascii_string): l:list ascii_char { List.Tot.length l = String.length s } = List.Tot.list_refb #(Char.char) #_ (String.list_of_string s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int.Cast.Full.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Literal.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": 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: LowStar.Literal.ascii_char -> x: FStar.UInt8.t{FStar.UInt8.v x = FStar.Char.int_of_char c}
Prims.Tot
[ "total" ]
[]
[ "LowStar.Literal.ascii_char", "FStar.Int.Cast.uint32_to_uint8", "Prims.unit", "FStar.Math.Lemmas.modulo_modulo_lemma", "FStar.UInt32.v", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "FStar.Char.char_code", "FStar.Char.u32_of_char", "FStar.UInt8.t", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Prims.op_GreaterThanOrEqual", "FStar.UInt8.v", "FStar.Char.int_of_char" ]
[]
false
false
false
false
false
let u8_of_ascii_char (c: ascii_char) : x: UInt8.t{UInt8.v x = Char.int_of_char c} =
let x32 = Char.u32_of_char c in assert_norm (pow2 24 * pow2 8 = pow2 32); Math.Lemmas.modulo_modulo_lemma (UInt32.v x32) (pow2 24) (pow2 8); Int.Cast.Full.uint32_to_uint8 x32
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem128
val low_lemma_store_mem128 (b:buffer128) (i:nat) (v:quad32) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b ) (ensures ( let m = S.update_heap128 (buffer_addr b h + scale16 i) v (get_heap h) in is_machine_heap_update (get_heap h) m /\ upd_heap h m == buffer_write b i v h ))
val low_lemma_store_mem128 (b:buffer128) (i:nat) (v:quad32) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b ) (ensures ( let m = S.update_heap128 (buffer_addr b h + scale16 i) v (get_heap h) in is_machine_heap_update (get_heap h) m /\ upd_heap h m == buffer_write b i v h ))
let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap'
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 990, "start_col": 0, "start_line": 979 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> v: Vale.X64.Memory.quad32 -> h: Vale.Arch.HeapImpl.vale_heap -> FStar.Pervasives.Lemma (requires i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b) (ensures (let m = Vale.Arch.MachineHeap_s.update_heap128 (Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i) v (Vale.X64.Memory_Sems.get_heap h) in Vale.Arch.MachineHeap_s.is_machine_heap_update (Vale.X64.Memory_Sems.get_heap h) m /\ Vale.X64.Memory_Sems.upd_heap h m == Vale.X64.Memory.buffer_write b i v h))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.X64.Memory.quad32", "Vale.Arch.HeapImpl.vale_heap", "Vale.Interop.update_buffer_up_mem", "Vale.Arch.HeapImpl._ih", "Prims.unit", "Vale.Interop.addrs_set_lemma_all", "Vale.X64.Memory_Sems.in_bounds128", "Vale.Arch.MachineHeap.frame_update_heap128", "Prims.op_Addition", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.vuint128", "Vale.X64.Memory.scale16", "Vale.X64.Memory_Sems.low_lemma_store_mem128_aux", "Vale.X64.Memory.store_mem128", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.update_heap128", "Vale.X64.Memory_Sems.same_domain", "Vale.X64.Memory_Sems.get_heap", "Vale.X64.Memory_Sems.valid_state_store_mem128_aux", "Vale.X64.Memory.lemma_store_mem128", "Vale.X64.Memory.lemma_valid_mem128" ]
[]
true
false
true
false
false
let low_lemma_store_mem128 b i v h =
lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap'
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_load_mem128_hi64
val low_lemma_load_mem128_hi64 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val64 (buffer_addr b h + scale16 i + 8) (get_heap h) == hi64 (buffer_read b i h) )
val low_lemma_load_mem128_hi64 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val64 (buffer_addr b h + scale16 i + 8) (get_heap h) == hi64 (buffer_read b i h) )
let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 1033, "start_col": 0, "start_line": 1028 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> h: Vale.Arch.HeapImpl.vale_heap -> FStar.Pervasives.Lemma (requires i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b) (ensures Vale.Arch.MachineHeap_s.get_heap_val64 (Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i + 8) (Vale.X64.Memory_Sems.get_heap h) == Vale.Arch.Types.hi64 (Vale.X64.Memory.buffer_read b i h))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.MachineHeap_s.get_heap_val32_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.get_heap_val64_reveal", "Vale.Arch.MachineHeap_s.get_heap_val128_reveal", "Vale.Arch.Types.hi64_reveal", "Vale.X64.Memory_Sems.low_lemma_load_mem128" ]
[]
true
false
true
false
false
let low_lemma_load_mem128_hi64 b i h =
low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal ()
false
LowStar.Literal.fsti
LowStar.Literal.buf_len_of_literal
val buf_len_of_literal (s: string) : ST.Stack (IB.ibuffer UInt8.t & UInt32.t) (requires (fun _ -> normalize (is_ascii_string s) /\ normalize (List.Tot.length (String.list_of_string s) < pow2 32))) (ensures (fun h0 r h1 -> let b, l = r in buffer_of_literal_post s h0 b h1 /\ UInt32.v l = normalize_term (List.Tot.length (String.list_of_string s)) /\ UInt32.v l = IB.length b))
val buf_len_of_literal (s: string) : ST.Stack (IB.ibuffer UInt8.t & UInt32.t) (requires (fun _ -> normalize (is_ascii_string s) /\ normalize (List.Tot.length (String.list_of_string s) < pow2 32))) (ensures (fun h0 r h1 -> let b, l = r in buffer_of_literal_post s h0 b h1 /\ UInt32.v l = normalize_term (List.Tot.length (String.list_of_string s)) /\ UInt32.v l = IB.length b))
let buf_len_of_literal (s: string): ST.Stack (IB.ibuffer UInt8.t & UInt32.t) (requires (fun _ -> normalize (is_ascii_string s) /\ normalize (List.Tot.length (String.list_of_string s) < pow2 32))) (ensures (fun h0 r h1 -> let b, l = r in buffer_of_literal_post s h0 b h1 /\ UInt32.v l = normalize_term (List.Tot.length (String.list_of_string s)) /\ UInt32.v l = IB.length b)) = [@@inline_let] let l = normalize_term (UInt32.uint_to_t (List.Tot.length (String.list_of_string s))) in buffer_of_literal s, l
{ "file_name": "ulib/LowStar.Literal.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 120, "start_col": 0, "start_line": 107 }
module LowStar.Literal module B = LowStar.Buffer module IB = LowStar.ImmutableBuffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST open FStar.Mul /// This module enables clients to make use of string literals in Low* as /// shorthand syntax for immutable, always-live uint8 buffers. See /// LowStar.printf for writing and printing string literals. /// .. note:: /// /// This module supersedes ``C.String``. /// As a reminder, the F* compiler enforces that string literals are UTF-8 /// encoded, and list_of_string returns the corresponding sequence of Unicode /// scalar values (see https://erratique.ch/software/uucp/doc/Uucp.html#uminimal) for an excellent /// crash course on Unicode. /// When compiling with KaRaMeL, string literals are printed as series of bytes, /// where non-alphanumeric characters are hex-encoded. For instance, if after reading /// the C standard, the user writes ``let x = "🤮"``, then KaRaMeL will generate /// ``const char *x = "\xf0\x9f\xa4\xae"``. /// String literals as buffers /// -------------------------- /// Therefore, in order to talk about the interpretation of a string literal as /// a series of bytes, we need to define the serialization of Unicode scalar values /// (as returned by ``String.list_of_string``) into bytes. This is a commendable and /// noble goal, but instead, we choose to restrict ourselves to the ASCII subset of /// UTF-8, where the byte encoding of a scalar value is the identity. let is_ascii_char (c: Char.char) = UInt32.lt (Char.u32_of_char c) 0x80ul let ascii_char = c:Char.char{is_ascii_char c} let is_ascii_string (s: string) = List.Tot.for_all is_ascii_char (String.list_of_string s) let ascii_string = s:string{is_ascii_string s} let for_all_tail #a p (l: list a { Cons? l }): Lemma (requires (List.Tot.for_all p l)) (ensures (List.Tot.for_all p (List.Tot.tl l))) = () let ascii_chars_of_ascii_string (s: ascii_string): l:list ascii_char { List.Tot.length l = String.length s } = List.Tot.list_refb #(Char.char) #_ (String.list_of_string s) let u8_of_ascii_char (c: ascii_char): x:UInt8.t{ UInt8.v x = Char.int_of_char c } = let x32 = Char.u32_of_char c in assert_norm (pow2 24 * pow2 8 = pow2 32); Math.Lemmas.modulo_modulo_lemma (UInt32.v x32) (pow2 24) (pow2 8); Int.Cast.Full.uint32_to_uint8 x32 /// This means that if a string literal only contains ASCII, then we can easily /// reflect its contents in terms of uint8's, without having to talk about the utf8 /// encoding. /// TODO: lemma: S.index (u8s_of_string s) i = String.index s i /// (cannot be proven right now because we don't know much about String.index) /// (is this even what we want? should we do everything in terms of list_of_string?) let u8s_of_ascii_string (s: ascii_string): ss:Seq.seq UInt8.t { Seq.length ss = List.Tot.length (String.list_of_string s) } = let cs = List.Tot.map u8_of_ascii_char (ascii_chars_of_ascii_string s) in Seq.seq_of_list cs unfold let buffer_of_literal_post (s: ascii_string) (h0: HS.mem) (b: IB.ibuffer UInt8.t) (h1: HS.mem) = IB.frameOf b == HS.root /\ // is this really useful? IB.recallable b /\ ( // An inlined version of alloc_post_mem_common, without the unused_in // condition, which would contradict the Stack annotation let s = u8s_of_ascii_string s in IB.live h1 b /\ Map.domain (HS.get_hmap h1) `Set.equal` Map.domain (HS.get_hmap h0) /\ HS.get_tip h1 == HS.get_tip h0 /\ B.(modifies loc_none h0 h1) /\ B.as_seq h1 b == s) /// Consequently, this function becomes in C a simple cast from ``const char *`` to /// ``char *``, since immutable buffers don't (yet) have the ``const`` attribute in /// KaRaMeL. (This is unsavory, and should be fixed later.) This way, a string /// literal can be seen as an immutable buffer and passed around as such. /// This function checks at extraction-time that its argument is a literal. val buffer_of_literal: (s: ascii_string) -> ST.Stack (IB.ibuffer UInt8.t) (requires (fun _ -> String.length s < pow2 32)) (ensures buffer_of_literal_post s) /// .. note:: /// /// This literal will be zero-terminated, but since we do not require that the /// string literal be zero-free, the trailing zero will be ignored and unused. This /// means that we won't be able to use the C standard library functions for string /// manipulation and will instead have to pass lengths at run-time. /// Rather than having to write ``assert_norm`` by hand, this convenient wrapper /// relies on the normalizer to discharge all the relevant proof obligations, and /// synthesizes the length of the resulting buffer. The pair has no cost: KaRaMeL /// guarantees that it will be eliminated.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int.Cast.Full.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Literal.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": 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
s: Prims.string -> FStar.HyperStack.ST.Stack (LowStar.ImmutableBuffer.ibuffer FStar.UInt8.t * FStar.UInt32.t)
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.string", "FStar.Pervasives.Native.Mktuple2", "LowStar.ImmutableBuffer.ibuffer", "FStar.UInt8.t", "FStar.UInt32.t", "FStar.Pervasives.Native.tuple2", "LowStar.Literal.buffer_of_literal", "FStar.Pervasives.normalize_term", "FStar.UInt32.uint_to_t", "FStar.List.Tot.Base.length", "FStar.String.char", "FStar.String.list_of_string", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Pervasives.normalize", "Prims.b2t", "LowStar.Literal.is_ascii_string", "Prims.op_LessThan", "Prims.pow2", "LowStar.Literal.buffer_of_literal_post", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt32.n", "FStar.UInt32.v", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "LowStar.Monotonic.Buffer.length", "LowStar.ImmutableBuffer.immutable_preorder" ]
[]
false
true
false
false
false
let buf_len_of_literal (s: string) : ST.Stack (IB.ibuffer UInt8.t & UInt32.t) (requires (fun _ -> normalize (is_ascii_string s) /\ normalize (List.Tot.length (String.list_of_string s) < pow2 32))) (ensures (fun h0 r h1 -> let b, l = r in buffer_of_literal_post s h0 b h1 /\ UInt32.v l = normalize_term (List.Tot.length (String.list_of_string s)) /\ UInt32.v l = IB.length b)) =
[@@ inline_let ]let l = normalize_term (UInt32.uint_to_t (List.Tot.length (String.list_of_string s))) in buffer_of_literal s, l
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_load_mem128_lo_hi_full
val low_lemma_load_mem128_lo_hi_full (b:buffer128) (i:nat) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ valid_layout_buffer b vfh.vf_layout h false /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in let ptr = buffer_addr b h + scale16 i in is_full_read vfh.vf_heap h b i /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ valid_addr64 (ptr + 8) (heap_get (coerce vfh)) /\ valid_mem128 ptr vfh.vf_heap /\ valid_taint_buf128 b vfh.vf_heap mt t ))
val low_lemma_load_mem128_lo_hi_full (b:buffer128) (i:nat) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ valid_layout_buffer b vfh.vf_layout h false /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in let ptr = buffer_addr b h + scale16 i in is_full_read vfh.vf_heap h b i /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ valid_addr64 (ptr + 8) (heap_get (coerce vfh)) /\ valid_mem128 ptr vfh.vf_heap /\ valid_taint_buf128 b vfh.vf_heap mt t ))
let low_lemma_load_mem128_lo_hi_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_valid_mem128_64 b i vfh.vf_heap; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 1071, "start_col": 0, "start_line": 1068 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () //let same_domain_update128_64 b i v h = // low_lemma_valid_mem128_64 b i (_ih h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i) v (get_heap h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i + 8) v (get_heap h) open Vale.Def.Types_s let frame_get_heap32 (ptr:int) (mem1 mem2:S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[i] == mem2.[i])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) = S.get_heap_val32_reveal () let update_heap128_lo (ptr:int) (v:quad32) (mem:S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr+8) mem /\ v.hi3 == S.get_heap_val32 (ptr+12) mem ) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr+4) v.lo1 (S.update_heap32 ptr v.lo0 mem)) = reveal_opaque (`%S.valid_addr128) S.valid_addr128; S.update_heap128_reveal (); let mem0 = S.update_heap32 ptr v.lo0 mem in let mem1 = S.update_heap32 (ptr+4) v.lo1 mem0 in Vale.Arch.MachineHeap.frame_update_heap32 ptr v.lo0 mem; Vale.Arch.MachineHeap.frame_update_heap32 (ptr+4) v.lo1 mem0; Vale.Arch.MachineHeap.same_domain_update32 ptr v.lo0 mem; Vale.Arch.MachineHeap.same_domain_update32 (ptr+4) v.lo1 mem0; frame_get_heap32 (ptr+8) mem mem1; frame_get_heap32 (ptr+12) mem mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+8) mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+12) mem1
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> vfh: Vale.Arch.HeapImpl.vale_full_heap -> t: Vale.Arch.HeapTypes_s.taint -> hid: Vale.Arch.HeapImpl.heaplet_id -> FStar.Pervasives.Lemma (requires (let _ = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid, Mkvale_heap_layout?.vl_taint (Mkvale_full_heap?.vf_layout vfh) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ h mt = _ in i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.valid_layout_buffer b (Mkvale_full_heap?.vf_layout vfh) h false /\ Vale.X64.Memory.valid_taint_buf128 b h mt t /\ Vale.X64.Memory.mem_inv vfh) <: Type0)) (ensures (let _ = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid, Mkvale_heap_layout?.vl_taint (Mkvale_full_heap?.vf_layout vfh) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ h mt = _ in let ptr = Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i in Vale.X64.Memory_Sems.is_full_read (Mkvale_full_heap?.vf_heap vfh) h b i /\ Vale.Arch.MachineHeap_s.valid_addr64 ptr (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh)) /\ Vale.Arch.MachineHeap_s.valid_addr64 (ptr + 8) (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh)) /\ Vale.X64.Memory.valid_mem128 ptr (Mkvale_full_heap?.vf_heap vfh) /\ Vale.X64.Memory.valid_taint_buf128 b (Mkvale_full_heap?.vf_heap vfh) mt t) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.HeapImpl.heaplet_id", "Prims.unit", "Vale.X64.Memory_Sems.low_lemma_valid_mem128_64", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "FStar.Pervasives.reveal_opaque", "Vale.Arch.HeapTypes_s.base_typ", "Vale.X64.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "FStar.Pervasives.Native.option", "Prims.bool", "Vale.Def.Prop_s.prop0", "Vale.X64.Memory.valid_layout_buffer_id" ]
[]
true
false
true
false
false
let low_lemma_load_mem128_lo_hi_full b i vfh t hid =
reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_valid_mem128_64 b i vfh.vf_heap; ()
false
FStar.Vector.Base.fsti
FStar.Vector.Base.len_t
val len_t : Prims.eqtype
let len_t = U32.t
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 72, "start_col": 0, "start_line": 72 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t" ]
[]
false
false
false
true
false
let len_t =
U32.t
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem128_full
val low_lemma_store_mem128_full (b:buffer128) (i:nat) (v:quad32) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let ptr = buffer_addr b h + scale16 i in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr128 ptr (heap_get (coerce vfh)) /\ is_full_update vfh (buffer_write b i v h) hid (S.update_heap128 ptr v (heap_get (coerce vfh))) (S.update_n ptr 16 (heap_taint (coerce vfh)) t) ))
val low_lemma_store_mem128_full (b:buffer128) (i:nat) (v:quad32) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let ptr = buffer_addr b h + scale16 i in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr128 ptr (heap_get (coerce vfh)) /\ is_full_update vfh (buffer_write b i v h) hid (S.update_heap128 ptr v (heap_get (coerce vfh))) (S.update_n ptr 16 (heap_taint (coerce vfh)) t) ))
let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 1007, "start_col": 0, "start_line": 992 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap'
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> v: Vale.X64.Memory.quad32 -> vfh: Vale.Arch.HeapImpl.vale_full_heap -> t: Vale.Arch.HeapTypes_s.taint -> hid: Vale.Arch.HeapImpl.heaplet_id -> FStar.Pervasives.Lemma (requires (let _ = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid, Mkvale_heap_layout?.vl_taint (Mkvale_full_heap?.vf_layout vfh) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ h mt = _ in i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b /\ Vale.X64.Memory.valid_layout_buffer b (Mkvale_full_heap?.vf_layout vfh) h true /\ Vale.X64.Memory.valid_taint_buf128 b h mt t /\ Vale.X64.Memory.mem_inv vfh) <: Type0)) (ensures (let h = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid in let ptr = Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i in Vale.X64.Memory.buffer_addr b (Mkvale_full_heap?.vf_heap vfh) == Vale.X64.Memory.buffer_addr b h /\ Vale.Arch.MachineHeap_s.valid_addr128 ptr (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh)) /\ Vale.X64.Memory_Sems.is_full_update vfh (Vale.X64.Memory.buffer_write b i v h) hid (Vale.Arch.MachineHeap_s.update_heap128 ptr v (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh))) (Vale.X64.Machine_Semantics_s.update_n ptr 16 (Vale.Arch.Heap.heap_taint (Vale.X64.Memory_Sems.coerce vfh)) t)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.X64.Memory.quad32", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.HeapImpl.heaplet_id", "Vale.Arch.HeapImpl.vale_heap", "Vale.X64.Memory.memtaint", "Prims.unit", "Vale.X64.Memory_Sems.lemma_is_full_update", "Vale.Arch.HeapImpl.__proj__ValeHeap__item__mh", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Arch.MachineHeap.same_mem_get_heap_val128", "Vale.X64.Memory_Sems.in_bounds128", "Vale.Arch.MachineHeap.frame_update_heap128", "Vale.X64.Memory_Sems.low_lemma_store_mem128", "Vale.Lib.Map16.get", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "FStar.Pervasives.reveal_opaque", "Vale.Arch.HeapTypes_s.base_typ", "Vale.X64.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "FStar.Pervasives.Native.option", "Prims.bool", "Vale.Def.Prop_s.prop0", "Vale.X64.Memory.valid_layout_buffer_id", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.update_heap128", "Vale.X64.Memory_Sems.get_heap", "Vale.X64.Memory.buffer_write", "Vale.X64.Memory.vuint128", "Vale.Arch.HeapTypes_s.memTaint_t", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "Prims.eq2", "FStar.Map.sel", "Prims.l_or", "Vale.Arch.Heap.heap_taint", "Vale.X64.Machine_Semantics_s.update_n", "Vale.X64.Memory_Sems.coerce", "Vale.Arch.Heap.heap_impl", "Vale.Arch.Heap.heap_get", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.scale16", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout" ]
[]
false
false
true
false
false
let low_lemma_store_mem128_full b i v vfh t hid =
let h, mt, hk = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; ()
false
FStar.Vector.Base.fsti
FStar.Vector.Base.equal
val equal : v1: FStar.Vector.Base.raw a l -> v2: FStar.Vector.Base.raw a l -> Prims.prop
let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2)
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 115, "start_col": 0, "start_line": 114 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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
v1: FStar.Vector.Base.raw a l -> v2: FStar.Vector.Base.raw a l -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.raw", "FStar.Seq.Base.equal", "FStar.Vector.Base.reveal", "Prims.prop" ]
[]
false
false
false
false
true
let equal (#a: Type) (#l: len_t) (v1 v2: raw a l) =
Seq.equal (reveal v1) (reveal v2)
false
FStar.Vector.Base.fsti
FStar.Vector.Base.op_String_Assignment
val op_String_Assignment : v: FStar.Vector.Base.raw a l -> i: FStar.Vector.Base.index_t v -> x: a -> FStar.Vector.Base.raw a l
let op_String_Assignment #a #l = update #a #l
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 52, "end_line": 173, "start_col": 7, "start_line": 173 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)] /// Extensional equality for vectors let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2) /// Extensional equality can be used to prove syntactic equality val extensionality: #a:Type -> #l:len_t -> v1:raw a l -> v2:raw a l -> Lemma (requires (equal v1 v2)) (ensures (v1 == v2)) //////////////////////////////////////////////////////////////////////////////// /// end of the basic model //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// A small set of basic operations on raw vectors, corresponding to the operations /// on sequences. Other operations can be derived from these, as we do for seq. /// -- init, index, update, append, slice //////////////////////////////////////////////////////////////////////////////// /// `index_t v`: is the type of a within-bounds index of `v` let index_t (#a:Type) (#l:len_t) (v:raw a l) = m:len_t{U32.v m < U32.v l} /// `init l contents`: /// initialize an `l`-sized vector using `contents i` for the `i`th element val init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Tot (raw a l) /// `index v i`: get the `i`th element of `v` val index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Tot a /// `v.[i]` is shorthand for `index v i` unfold let op_String_Access #a #l = index #a #l /// `update v i x`: /// - a new vector that differs from `v` only at index `i`, where it contains `x`. /// - Incurs a full copy in KaRaMeL /// - In OCaml, the new vector shares as much as possible with `v` val update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Tot (raw a l)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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.Vector.Base.raw a l -> i: FStar.Vector.Base.index_t v -> x: a -> FStar.Vector.Base.raw a l
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.update", "FStar.Vector.Base.raw", "FStar.Vector.Base.index_t" ]
[]
false
false
false
false
false
let ( .[]<- ) #a #l =
update #a #l
false
FStar.Vector.Base.fsti
FStar.Vector.Base.op_String_Access
val op_String_Access : v: FStar.Vector.Base.raw a l -> i: FStar.Vector.Base.index_t v -> a
let op_String_Access #a #l = index #a #l
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 158, "start_col": 7, "start_line": 158 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)] /// Extensional equality for vectors let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2) /// Extensional equality can be used to prove syntactic equality val extensionality: #a:Type -> #l:len_t -> v1:raw a l -> v2:raw a l -> Lemma (requires (equal v1 v2)) (ensures (v1 == v2)) //////////////////////////////////////////////////////////////////////////////// /// end of the basic model //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// A small set of basic operations on raw vectors, corresponding to the operations /// on sequences. Other operations can be derived from these, as we do for seq. /// -- init, index, update, append, slice //////////////////////////////////////////////////////////////////////////////// /// `index_t v`: is the type of a within-bounds index of `v` let index_t (#a:Type) (#l:len_t) (v:raw a l) = m:len_t{U32.v m < U32.v l} /// `init l contents`: /// initialize an `l`-sized vector using `contents i` for the `i`th element val init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Tot (raw a l) /// `index v i`: get the `i`th element of `v` val index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Tot a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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.Vector.Base.raw a l -> i: FStar.Vector.Base.index_t v -> a
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.index", "FStar.Vector.Base.raw", "FStar.Vector.Base.index_t" ]
[]
false
false
false
false
false
let ( .[] ) #a #l =
index #a #l
false
FStar.Vector.Base.fsti
FStar.Vector.Base.index_t
val index_t : v: FStar.Vector.Base.raw a l -> Type0
let index_t (#a:Type) (#l:len_t) (v:raw a l) = m:len_t{U32.v m < U32.v l}
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 139, "start_col": 0, "start_line": 138 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)] /// Extensional equality for vectors let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2) /// Extensional equality can be used to prove syntactic equality val extensionality: #a:Type -> #l:len_t -> v1:raw a l -> v2:raw a l -> Lemma (requires (equal v1 v2)) (ensures (v1 == v2)) //////////////////////////////////////////////////////////////////////////////// /// end of the basic model //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// A small set of basic operations on raw vectors, corresponding to the operations /// on sequences. Other operations can be derived from these, as we do for seq. /// -- init, index, update, append, slice ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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.Vector.Base.raw a l -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.raw", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v" ]
[]
false
false
false
false
true
let index_t (#a: Type) (#l: len_t) (v: raw a l) =
m: len_t{U32.v m < U32.v l}
false
LList.Invariant.fst
LList.Invariant.mk_cell
val mk_cell (n: t 'a) (d:'a) : Pure (cell 'a) (requires True) (ensures fun c -> next c == n /\ data c == d)
val mk_cell (n: t 'a) (d:'a) : Pure (cell 'a) (requires True) (ensures fun c -> next c == n /\ data c == d)
let mk_cell (n: t 'a) (d:'a) = { next = n; data = d }
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 1, "end_line": 40, "start_col": 0, "start_line": 37 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
n: LList.Invariant.t 'a -> d: 'a -> Prims.Pure (LList.Invariant.cell 'a)
Prims.Pure
[]
[]
[ "LList.Invariant.t", "LList.Invariant.Mkcell", "LList.Invariant.cell" ]
[]
false
false
false
false
false
let mk_cell (n: t 'a) (d: 'a) =
{ next = n; data = d }
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem128_lo64
val low_lemma_store_mem128_lo64 (b:buffer128) (i:nat) (v:nat64) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b ) (ensures ( let v' = insert_nat64 (buffer_read b i h) v 0 in let m = S.update_heap64 (buffer_addr b h + scale16 i) v (get_heap h) in is_machine_heap_update (get_heap h) m /\ upd_heap h m == buffer_write b i v' h ))
val low_lemma_store_mem128_lo64 (b:buffer128) (i:nat) (v:nat64) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b ) (ensures ( let v' = insert_nat64 (buffer_read b i h) v 0 in let m = S.update_heap64 (buffer_addr b h + scale16 i) v (get_heap h) in is_machine_heap_update (get_heap h) m /\ upd_heap h m == buffer_write b i v' h ))
let low_lemma_store_mem128_lo64 b i v h = let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 0 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; S.get_heap_val128_reveal (); update_heap128_lo ptr v' (get_heap h); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 1083, "start_col": 0, "start_line": 1073 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () //let same_domain_update128_64 b i v h = // low_lemma_valid_mem128_64 b i (_ih h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i) v (get_heap h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i + 8) v (get_heap h) open Vale.Def.Types_s let frame_get_heap32 (ptr:int) (mem1 mem2:S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[i] == mem2.[i])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) = S.get_heap_val32_reveal () let update_heap128_lo (ptr:int) (v:quad32) (mem:S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr+8) mem /\ v.hi3 == S.get_heap_val32 (ptr+12) mem ) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr+4) v.lo1 (S.update_heap32 ptr v.lo0 mem)) = reveal_opaque (`%S.valid_addr128) S.valid_addr128; S.update_heap128_reveal (); let mem0 = S.update_heap32 ptr v.lo0 mem in let mem1 = S.update_heap32 (ptr+4) v.lo1 mem0 in Vale.Arch.MachineHeap.frame_update_heap32 ptr v.lo0 mem; Vale.Arch.MachineHeap.frame_update_heap32 (ptr+4) v.lo1 mem0; Vale.Arch.MachineHeap.same_domain_update32 ptr v.lo0 mem; Vale.Arch.MachineHeap.same_domain_update32 (ptr+4) v.lo1 mem0; frame_get_heap32 (ptr+8) mem mem1; frame_get_heap32 (ptr+12) mem mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+8) mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+12) mem1 let low_lemma_load_mem128_lo_hi_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_valid_mem128_64 b i vfh.vf_heap; ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> v: Vale.Def.Types_s.nat64 -> h: Vale.Arch.HeapImpl.vale_heap -> FStar.Pervasives.Lemma (requires i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b) (ensures (let v' = Vale.Def.Types_s.insert_nat64 (Vale.X64.Memory.buffer_read b i h) v 0 in let m = Vale.Arch.MachineHeap_s.update_heap64 (Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i) v (Vale.X64.Memory_Sems.get_heap h) in Vale.Arch.MachineHeap_s.is_machine_heap_update (Vale.X64.Memory_Sems.get_heap h) m /\ Vale.X64.Memory_Sems.upd_heap h m == Vale.X64.Memory.buffer_write b i v' h))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.Def.Types_s.nat64", "Vale.Arch.HeapImpl.vale_heap", "Vale.Def.Types_s.insert_nat64_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.update_heap32_reveal", "Vale.Arch.MachineHeap_s.update_heap64_reveal", "Vale.X64.Memory_Sems.update_heap128_lo", "Vale.X64.Memory_Sems.get_heap", "Vale.Arch.MachineHeap_s.get_heap_val128_reveal", "Vale.X64.Memory_Sems.low_lemma_store_mem128", "Vale.X64.Memory_Sems.low_lemma_load_mem128", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.insert_nat64", "Vale.X64.Memory.base_typ_as_vale_type", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.X64.Memory.buffer_read", "Vale.X64.Memory.vuint128", "Prims.int", "Prims.op_Addition", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.scale16" ]
[]
true
false
true
false
false
let low_lemma_store_mem128_lo64 b i v h =
let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 0 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; S.get_heap_val128_reveal (); update_heap128_lo ptr v' (get_heap h); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal ()
false
FStar.Vector.Base.fsti
FStar.Vector.Base.op_Array_Assignment
val ( .()<- ) (#a: Type) (x: t a) (i: index_t (as_raw x)) (v: a) : Tot (t a)
val ( .()<- ) (#a: Type) (x: t a) (i: index_t (as_raw x)) (v: a) : Tot (t a)
let op_Array_Assignment (#a:Type) (x:t a) (i:index_t (as_raw x)) (v:a) : Tot (t a) = from_raw ((as_raw x).[i] <- v)
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 323, "start_col": 0, "start_line": 317 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)] /// Extensional equality for vectors let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2) /// Extensional equality can be used to prove syntactic equality val extensionality: #a:Type -> #l:len_t -> v1:raw a l -> v2:raw a l -> Lemma (requires (equal v1 v2)) (ensures (v1 == v2)) //////////////////////////////////////////////////////////////////////////////// /// end of the basic model //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// A small set of basic operations on raw vectors, corresponding to the operations /// on sequences. Other operations can be derived from these, as we do for seq. /// -- init, index, update, append, slice //////////////////////////////////////////////////////////////////////////////// /// `index_t v`: is the type of a within-bounds index of `v` let index_t (#a:Type) (#l:len_t) (v:raw a l) = m:len_t{U32.v m < U32.v l} /// `init l contents`: /// initialize an `l`-sized vector using `contents i` for the `i`th element val init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Tot (raw a l) /// `index v i`: get the `i`th element of `v` val index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Tot a /// `v.[i]` is shorthand for `index v i` unfold let op_String_Access #a #l = index #a #l /// `update v i x`: /// - a new vector that differs from `v` only at index `i`, where it contains `x`. /// - Incurs a full copy in KaRaMeL /// - In OCaml, the new vector shares as much as possible with `v` val update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Tot (raw a l) /// `v.[i] <- x` is shorthand for `update v i x` unfold let op_String_Assignment #a #l = update #a #l /// `append v1 v2`: /// - requires proving that the sum of the lengths of v1 and v2 still fit in a u32 /// - Incurs a full copy in KaRaMeL /// - Amortized constant time in OCaml val append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Tot (raw a U32.(l1 +^ l2)) /// `v1 @| v2`: shorthand for `append v1 v2` unfold let (@|) #a #l1 #l2 = append #a #l1 #l2 /// `sub v i j`: /// - the sub-vector of `v` starting from index `i` up to, but not including, `j` /// - Constant time in KaRaMeL (just an addition on a pointer) /// - Worst-case (log l) time in OCaml val sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Tot (raw a U32.(j -^ i)) //////////////////////////////////////////////////////////////////////////////// /// Lemmas about the basic operations, all rather boring /// -- Each is just a lifting specifying the corresponding operation on seq //////////////////////////////////////////////////////////////////////////////// val reveal_init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Lemma (ensures (reveal (init l contents) == Seq.init (U32.v l) contents)) [SMTPat (init l contents)] val reveal_index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Lemma (ensures (v.[i] == Seq.index (reveal v) (U32.v i))) [SMTPat (v.[i])] val reveal_update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Lemma (ensures (reveal (v.[i] <- x) == Seq.upd (reveal v) (U32.v i) x)) [SMTPat (v.[i] <- x)] val reveal_append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Lemma (ensures (reveal (v1 @| v2) == Seq.append (reveal v1) (reveal v2))) [SMTPat (v1 @| v2)] val reveal_sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Lemma (ensures (reveal (sub v i j) == S.slice (reveal v) (U32.v i) (U32.v j))) [SMTPat (sub v i j)] //////////////////////////////////////////////////////////////////////////////// /// Now, we have `Vector.Base.t`, abstractly, a raw vector paired with its u32 length //////////////////////////////////////////////////////////////////////////////// val t: a:Type u#a -> Type u#a /// Unlike raw vectors, t-vectors support decidable equality val t_has_eq: a:Type u#a -> Lemma (requires (hasEq a)) (ensures (hasEq (t a))) [SMTPat (hasEq (t a))] /// The length of a t-vector is a dynamically computable u32 val len: #a:Type -> t a -> len_t /// A convenience to access the length of a t-vector as a nat [@@"deprecated: this will be moved to the ghost effect"] let length (#a:Type) (x:t a) : nat = U32.v (len x) /// Access the underlying raw vector val as_raw: #a:Type -> x:t a -> raw a (len x) /// Promote a raw vector val from_raw: #a:Type -> #l:len_t -> v:raw a l -> x:t a{len x = l} /// as_raw and from_raw are mutual inverses val as_raw_from_raw: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (as_raw (from_raw v) == v)) [SMTPat (from_raw v)] val from_raw_as_raw: #a:Type -> x:t a -> Lemma (ensures (from_raw (as_raw x) == x)) [SMTPat (as_raw x)] /// `v.(i)` accesses the ith element of v unfold let op_Array_Access (#a:Type) (x:t a) (i:index_t (as_raw x)) : Tot a = (as_raw x).[i] /// `v.(i) <- x` is a new t-vector that differs from v only at i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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: FStar.Vector.Base.t a -> i: FStar.Vector.Base.index_t (FStar.Vector.Base.as_raw x) -> v: a -> FStar.Vector.Base.t a
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.t", "FStar.Vector.Base.index_t", "FStar.Vector.Base.len", "FStar.Vector.Base.as_raw", "FStar.Vector.Base.from_raw", "FStar.Vector.Base.op_String_Assignment" ]
[]
false
false
false
false
false
let ( .()<- ) (#a: Type) (x: t a) (i: index_t (as_raw x)) (v: a) : Tot (t a) =
from_raw ((as_raw x).[ i ] <- v)
false
FStar.Vector.Base.fsti
FStar.Vector.Base.op_Array_Access
val ( .() ) (#a: Type) (x: t a) (i: index_t (as_raw x)) : Tot a
val ( .() ) (#a: Type) (x: t a) (i: index_t (as_raw x)) : Tot a
let op_Array_Access (#a:Type) (x:t a) (i:index_t (as_raw x)) : Tot a = (as_raw x).[i]
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 313, "start_col": 0, "start_line": 308 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)] /// Extensional equality for vectors let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2) /// Extensional equality can be used to prove syntactic equality val extensionality: #a:Type -> #l:len_t -> v1:raw a l -> v2:raw a l -> Lemma (requires (equal v1 v2)) (ensures (v1 == v2)) //////////////////////////////////////////////////////////////////////////////// /// end of the basic model //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// A small set of basic operations on raw vectors, corresponding to the operations /// on sequences. Other operations can be derived from these, as we do for seq. /// -- init, index, update, append, slice //////////////////////////////////////////////////////////////////////////////// /// `index_t v`: is the type of a within-bounds index of `v` let index_t (#a:Type) (#l:len_t) (v:raw a l) = m:len_t{U32.v m < U32.v l} /// `init l contents`: /// initialize an `l`-sized vector using `contents i` for the `i`th element val init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Tot (raw a l) /// `index v i`: get the `i`th element of `v` val index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Tot a /// `v.[i]` is shorthand for `index v i` unfold let op_String_Access #a #l = index #a #l /// `update v i x`: /// - a new vector that differs from `v` only at index `i`, where it contains `x`. /// - Incurs a full copy in KaRaMeL /// - In OCaml, the new vector shares as much as possible with `v` val update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Tot (raw a l) /// `v.[i] <- x` is shorthand for `update v i x` unfold let op_String_Assignment #a #l = update #a #l /// `append v1 v2`: /// - requires proving that the sum of the lengths of v1 and v2 still fit in a u32 /// - Incurs a full copy in KaRaMeL /// - Amortized constant time in OCaml val append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Tot (raw a U32.(l1 +^ l2)) /// `v1 @| v2`: shorthand for `append v1 v2` unfold let (@|) #a #l1 #l2 = append #a #l1 #l2 /// `sub v i j`: /// - the sub-vector of `v` starting from index `i` up to, but not including, `j` /// - Constant time in KaRaMeL (just an addition on a pointer) /// - Worst-case (log l) time in OCaml val sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Tot (raw a U32.(j -^ i)) //////////////////////////////////////////////////////////////////////////////// /// Lemmas about the basic operations, all rather boring /// -- Each is just a lifting specifying the corresponding operation on seq //////////////////////////////////////////////////////////////////////////////// val reveal_init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Lemma (ensures (reveal (init l contents) == Seq.init (U32.v l) contents)) [SMTPat (init l contents)] val reveal_index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Lemma (ensures (v.[i] == Seq.index (reveal v) (U32.v i))) [SMTPat (v.[i])] val reveal_update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Lemma (ensures (reveal (v.[i] <- x) == Seq.upd (reveal v) (U32.v i) x)) [SMTPat (v.[i] <- x)] val reveal_append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Lemma (ensures (reveal (v1 @| v2) == Seq.append (reveal v1) (reveal v2))) [SMTPat (v1 @| v2)] val reveal_sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Lemma (ensures (reveal (sub v i j) == S.slice (reveal v) (U32.v i) (U32.v j))) [SMTPat (sub v i j)] //////////////////////////////////////////////////////////////////////////////// /// Now, we have `Vector.Base.t`, abstractly, a raw vector paired with its u32 length //////////////////////////////////////////////////////////////////////////////// val t: a:Type u#a -> Type u#a /// Unlike raw vectors, t-vectors support decidable equality val t_has_eq: a:Type u#a -> Lemma (requires (hasEq a)) (ensures (hasEq (t a))) [SMTPat (hasEq (t a))] /// The length of a t-vector is a dynamically computable u32 val len: #a:Type -> t a -> len_t /// A convenience to access the length of a t-vector as a nat [@@"deprecated: this will be moved to the ghost effect"] let length (#a:Type) (x:t a) : nat = U32.v (len x) /// Access the underlying raw vector val as_raw: #a:Type -> x:t a -> raw a (len x) /// Promote a raw vector val from_raw: #a:Type -> #l:len_t -> v:raw a l -> x:t a{len x = l} /// as_raw and from_raw are mutual inverses val as_raw_from_raw: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (as_raw (from_raw v) == v)) [SMTPat (from_raw v)] val from_raw_as_raw: #a:Type -> x:t a -> Lemma (ensures (from_raw (as_raw x) == x)) [SMTPat (as_raw x)] /// `v.(i)` accesses the ith element of v
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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: FStar.Vector.Base.t a -> i: FStar.Vector.Base.index_t (FStar.Vector.Base.as_raw x) -> a
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.t", "FStar.Vector.Base.index_t", "FStar.Vector.Base.len", "FStar.Vector.Base.as_raw", "FStar.Vector.Base.op_String_Access" ]
[]
false
false
false
false
false
let ( .() ) (#a: Type) (x: t a) (i: index_t (as_raw x)) : Tot a =
(as_raw x).[ i ]
false
FStar.Vector.Base.fsti
FStar.Vector.Base.raw_length
val raw_length (#a: Type) (#l: len_t) (v: raw a l) : GTot nat
val raw_length (#a: Type) (#l: len_t) (v: raw a l) : GTot nat
let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 82, "start_col": 0, "start_line": 82 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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.Vector.Base.raw a l -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Vector.Base.len_t", "FStar.Vector.Base.raw", "FStar.UInt32.v", "Prims.nat" ]
[]
false
false
false
false
false
let raw_length (#a: Type) (#l: len_t) (v: raw a l) : GTot nat =
U32.v l
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem128_hi64
val low_lemma_store_mem128_hi64 (b:buffer128) (i:nat) (v:nat64) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b ) (ensures ( let v' = insert_nat64 (buffer_read b i h) v 1 in let m = S.update_heap64 (buffer_addr b h + scale16 i + 8) v (get_heap h) in is_machine_heap_update (get_heap h) m /\ upd_heap h m == buffer_write b i v' h) )
val low_lemma_store_mem128_hi64 (b:buffer128) (i:nat) (v:nat64) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b ) (ensures ( let v' = insert_nat64 (buffer_read b i h) v 1 in let m = S.update_heap64 (buffer_addr b h + scale16 i + 8) v (get_heap h) in is_machine_heap_update (get_heap h) m /\ upd_heap h m == buffer_write b i v' h) )
let low_lemma_store_mem128_hi64 b i v h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 1 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; assert (S.valid_addr128 ptr (get_heap h)); Vale.Arch.MachineHeap.update_heap32_get_heap32 ptr (get_heap h); Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+4) (get_heap h); S.get_heap_val128_reveal (); S.update_heap128_reveal (); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 1122, "start_col": 0, "start_line": 1108 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () //let same_domain_update128_64 b i v h = // low_lemma_valid_mem128_64 b i (_ih h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i) v (get_heap h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i + 8) v (get_heap h) open Vale.Def.Types_s let frame_get_heap32 (ptr:int) (mem1 mem2:S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[i] == mem2.[i])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) = S.get_heap_val32_reveal () let update_heap128_lo (ptr:int) (v:quad32) (mem:S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr+8) mem /\ v.hi3 == S.get_heap_val32 (ptr+12) mem ) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr+4) v.lo1 (S.update_heap32 ptr v.lo0 mem)) = reveal_opaque (`%S.valid_addr128) S.valid_addr128; S.update_heap128_reveal (); let mem0 = S.update_heap32 ptr v.lo0 mem in let mem1 = S.update_heap32 (ptr+4) v.lo1 mem0 in Vale.Arch.MachineHeap.frame_update_heap32 ptr v.lo0 mem; Vale.Arch.MachineHeap.frame_update_heap32 (ptr+4) v.lo1 mem0; Vale.Arch.MachineHeap.same_domain_update32 ptr v.lo0 mem; Vale.Arch.MachineHeap.same_domain_update32 (ptr+4) v.lo1 mem0; frame_get_heap32 (ptr+8) mem mem1; frame_get_heap32 (ptr+12) mem mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+8) mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+12) mem1 let low_lemma_load_mem128_lo_hi_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_valid_mem128_64 b i vfh.vf_heap; () let low_lemma_store_mem128_lo64 b i v h = let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 0 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; S.get_heap_val128_reveal (); update_heap128_lo ptr v' (get_heap h); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal () let low_lemma_store_mem128_lo64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let v' = insert_nat64 (buffer_read b i hk) v 0 in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v' (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v' hk in let mhk' = S.update_heap128 ptr v' (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v' h; low_lemma_store_mem128 b i v' (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v' h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v' hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v' t; low_lemma_store_mem128_lo64 b i v h; low_lemma_valid_mem128_64 b i h; assert (Map.equal mt (S.update_n (buffer_addr b h + scale16 i) 8 mt t)); () #push-options "--z3rlimit 20 --using_facts_from '* -LowStar.Monotonic.Buffer.loc_disjoint_includes_r'"
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> v: Vale.Def.Types_s.nat64 -> h: Vale.Arch.HeapImpl.vale_heap -> FStar.Pervasives.Lemma (requires i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b) (ensures (let v' = Vale.Def.Types_s.insert_nat64 (Vale.X64.Memory.buffer_read b i h) v 1 in let m = Vale.Arch.MachineHeap_s.update_heap64 (Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i + 8) v (Vale.X64.Memory_Sems.get_heap h) in Vale.Arch.MachineHeap_s.is_machine_heap_update (Vale.X64.Memory_Sems.get_heap h) m /\ Vale.X64.Memory_Sems.upd_heap h m == Vale.X64.Memory.buffer_write b i v' h))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.Def.Types_s.nat64", "Vale.Arch.HeapImpl.vale_heap", "Vale.Def.Types_s.insert_nat64_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.update_heap32_reveal", "Vale.Arch.MachineHeap_s.update_heap64_reveal", "Vale.Arch.MachineHeap_s.update_heap128_reveal", "Vale.Arch.MachineHeap_s.get_heap_val128_reveal", "Vale.Arch.MachineHeap.update_heap32_get_heap32", "Prims.op_Addition", "Vale.X64.Memory_Sems.get_heap", "Prims._assert", "Prims.b2t", "Vale.Arch.MachineHeap_s.valid_addr128", "Vale.X64.Memory_Sems.low_lemma_store_mem128", "Vale.X64.Memory_Sems.low_lemma_load_mem128", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.insert_nat64", "Vale.X64.Memory.base_typ_as_vale_type", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.X64.Memory.buffer_read", "Vale.X64.Memory.vuint128", "Prims.int", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.scale16", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.bool" ]
[]
true
false
true
false
false
let low_lemma_store_mem128_hi64 b i v h =
reveal_opaque (`%S.valid_addr128) S.valid_addr128; let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 1 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; assert (S.valid_addr128 ptr (get_heap h)); Vale.Arch.MachineHeap.update_heap32_get_heap32 ptr (get_heap h); Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr + 4) (get_heap h); S.get_heap_val128_reveal (); S.update_heap128_reveal (); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal ()
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem128_lo64_full
val low_lemma_store_mem128_lo64_full (b:buffer128) (i:nat) (v:nat64) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let ptr = buffer_addr b h + scale16 i in let v' = insert_nat64 (buffer_read b i h) v 0 in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ is_full_update vfh (buffer_write b i v' h) hid (S.update_heap64 ptr v (heap_get (coerce vfh))) (S.update_n ptr 8 (heap_taint (coerce vfh)) t) ))
val low_lemma_store_mem128_lo64_full (b:buffer128) (i:nat) (v:nat64) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let ptr = buffer_addr b h + scale16 i in let v' = insert_nat64 (buffer_read b i h) v 0 in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ is_full_update vfh (buffer_write b i v' h) hid (S.update_heap64 ptr v (heap_get (coerce vfh))) (S.update_n ptr 8 (heap_taint (coerce vfh)) t) ))
let low_lemma_store_mem128_lo64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let v' = insert_nat64 (buffer_read b i hk) v 0 in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v' (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v' hk in let mhk' = S.update_heap128 ptr v' (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v' h; low_lemma_store_mem128 b i v' (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v' h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v' hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v' t; low_lemma_store_mem128_lo64 b i v h; low_lemma_valid_mem128_64 b i h; assert (Map.equal mt (S.update_n (buffer_addr b h + scale16 i) 8 mt t)); ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 1104, "start_col": 0, "start_line": 1085 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () //let same_domain_update128_64 b i v h = // low_lemma_valid_mem128_64 b i (_ih h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i) v (get_heap h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i + 8) v (get_heap h) open Vale.Def.Types_s let frame_get_heap32 (ptr:int) (mem1 mem2:S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[i] == mem2.[i])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) = S.get_heap_val32_reveal () let update_heap128_lo (ptr:int) (v:quad32) (mem:S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr+8) mem /\ v.hi3 == S.get_heap_val32 (ptr+12) mem ) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr+4) v.lo1 (S.update_heap32 ptr v.lo0 mem)) = reveal_opaque (`%S.valid_addr128) S.valid_addr128; S.update_heap128_reveal (); let mem0 = S.update_heap32 ptr v.lo0 mem in let mem1 = S.update_heap32 (ptr+4) v.lo1 mem0 in Vale.Arch.MachineHeap.frame_update_heap32 ptr v.lo0 mem; Vale.Arch.MachineHeap.frame_update_heap32 (ptr+4) v.lo1 mem0; Vale.Arch.MachineHeap.same_domain_update32 ptr v.lo0 mem; Vale.Arch.MachineHeap.same_domain_update32 (ptr+4) v.lo1 mem0; frame_get_heap32 (ptr+8) mem mem1; frame_get_heap32 (ptr+12) mem mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+8) mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+12) mem1 let low_lemma_load_mem128_lo_hi_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_valid_mem128_64 b i vfh.vf_heap; () let low_lemma_store_mem128_lo64 b i v h = let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 0 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; S.get_heap_val128_reveal (); update_heap128_lo ptr v' (get_heap h); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> v: Vale.Def.Types_s.nat64 -> vfh: Vale.Arch.HeapImpl.vale_full_heap -> t: Vale.Arch.HeapTypes_s.taint -> hid: Vale.Arch.HeapImpl.heaplet_id -> FStar.Pervasives.Lemma (requires (let _ = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid, Mkvale_heap_layout?.vl_taint (Mkvale_full_heap?.vf_layout vfh) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ h mt = _ in i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b /\ Vale.X64.Memory.valid_layout_buffer b (Mkvale_full_heap?.vf_layout vfh) h true /\ Vale.X64.Memory.valid_taint_buf128 b h mt t /\ Vale.X64.Memory.mem_inv vfh) <: Type0)) (ensures (let h = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid in let ptr = Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i in let v' = Vale.Def.Types_s.insert_nat64 (Vale.X64.Memory.buffer_read b i h) v 0 in Vale.X64.Memory.buffer_addr b (Mkvale_full_heap?.vf_heap vfh) == Vale.X64.Memory.buffer_addr b h /\ Vale.Arch.MachineHeap_s.valid_addr64 ptr (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh)) /\ Vale.X64.Memory_Sems.is_full_update vfh (Vale.X64.Memory.buffer_write b i v' h) hid (Vale.Arch.MachineHeap_s.update_heap64 ptr v (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh))) (Vale.X64.Machine_Semantics_s.update_n ptr 8 (Vale.Arch.Heap.heap_taint (Vale.X64.Memory_Sems.coerce vfh)) t)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.Def.Types_s.nat64", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.HeapImpl.heaplet_id", "Vale.Arch.HeapImpl.vale_heap", "FStar.Map.t", "Prims.int", "FStar.Set.equal", "FStar.Map.domain", "FStar.Set.complement", "FStar.Set.empty", "Prims.unit", "Prims._assert", "FStar.Map.equal", "Vale.X64.Machine_Semantics_s.update_n", "Prims.op_Addition", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.vuint128", "Vale.X64.Memory.scale16", "Vale.X64.Memory_Sems.low_lemma_valid_mem128_64", "Vale.X64.Memory_Sems.low_lemma_store_mem128_lo64", "Vale.X64.Memory_Sems.lemma_is_full_update", "Vale.Arch.HeapImpl.__proj__ValeHeap__item__mh", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Arch.MachineHeap.same_mem_get_heap_val128", "Vale.X64.Memory_Sems.in_bounds128", "Vale.Arch.MachineHeap.frame_update_heap128", "Vale.X64.Memory_Sems.low_lemma_store_mem128", "Vale.Lib.Map16.get", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "FStar.Pervasives.reveal_opaque", "Vale.Arch.HeapTypes_s.base_typ", "Vale.X64.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "FStar.Pervasives.Native.option", "Prims.bool", "Vale.Def.Prop_s.prop0", "Vale.X64.Memory.valid_layout_buffer_id", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.update_heap128", "Vale.X64.Memory_Sems.get_heap", "Vale.X64.Memory.buffer_write", "Vale.Arch.HeapTypes_s.memTaint_t", "Prims.l_Forall", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "FStar.Map.sel", "Prims.l_or", "Vale.Arch.Heap.heap_taint", "Vale.X64.Memory_Sems.coerce", "Vale.Arch.Heap.heap_impl", "Vale.Arch.Heap.heap_get", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.insert_nat64", "Vale.X64.Memory.buffer_read", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout" ]
[]
false
false
true
false
false
let low_lemma_store_mem128_lo64_full b i v vfh t hid =
let h, mt, hk = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let v' = insert_nat64 (buffer_read b i hk) v 0 in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v' (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v' hk in let mhk' = S.update_heap128 ptr v' (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v' h; low_lemma_store_mem128 b i v' (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v' h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v' hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v' t; low_lemma_store_mem128_lo64 b i v h; low_lemma_valid_mem128_64 b i h; assert (Map.equal mt (S.update_n (buffer_addr b h + scale16 i) 8 mt t)); ()
false
FStar.Vector.Base.fsti
FStar.Vector.Base.length
val length (#a: Type) (x: t a) : nat
val length (#a: Type) (x: t a) : nat
let length (#a:Type) (x:t a) : nat = U32.v (len x)
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 277, "start_col": 0, "start_line": 277 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)] /// Extensional equality for vectors let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2) /// Extensional equality can be used to prove syntactic equality val extensionality: #a:Type -> #l:len_t -> v1:raw a l -> v2:raw a l -> Lemma (requires (equal v1 v2)) (ensures (v1 == v2)) //////////////////////////////////////////////////////////////////////////////// /// end of the basic model //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// A small set of basic operations on raw vectors, corresponding to the operations /// on sequences. Other operations can be derived from these, as we do for seq. /// -- init, index, update, append, slice //////////////////////////////////////////////////////////////////////////////// /// `index_t v`: is the type of a within-bounds index of `v` let index_t (#a:Type) (#l:len_t) (v:raw a l) = m:len_t{U32.v m < U32.v l} /// `init l contents`: /// initialize an `l`-sized vector using `contents i` for the `i`th element val init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Tot (raw a l) /// `index v i`: get the `i`th element of `v` val index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Tot a /// `v.[i]` is shorthand for `index v i` unfold let op_String_Access #a #l = index #a #l /// `update v i x`: /// - a new vector that differs from `v` only at index `i`, where it contains `x`. /// - Incurs a full copy in KaRaMeL /// - In OCaml, the new vector shares as much as possible with `v` val update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Tot (raw a l) /// `v.[i] <- x` is shorthand for `update v i x` unfold let op_String_Assignment #a #l = update #a #l /// `append v1 v2`: /// - requires proving that the sum of the lengths of v1 and v2 still fit in a u32 /// - Incurs a full copy in KaRaMeL /// - Amortized constant time in OCaml val append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Tot (raw a U32.(l1 +^ l2)) /// `v1 @| v2`: shorthand for `append v1 v2` unfold let (@|) #a #l1 #l2 = append #a #l1 #l2 /// `sub v i j`: /// - the sub-vector of `v` starting from index `i` up to, but not including, `j` /// - Constant time in KaRaMeL (just an addition on a pointer) /// - Worst-case (log l) time in OCaml val sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Tot (raw a U32.(j -^ i)) //////////////////////////////////////////////////////////////////////////////// /// Lemmas about the basic operations, all rather boring /// -- Each is just a lifting specifying the corresponding operation on seq //////////////////////////////////////////////////////////////////////////////// val reveal_init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Lemma (ensures (reveal (init l contents) == Seq.init (U32.v l) contents)) [SMTPat (init l contents)] val reveal_index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Lemma (ensures (v.[i] == Seq.index (reveal v) (U32.v i))) [SMTPat (v.[i])] val reveal_update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Lemma (ensures (reveal (v.[i] <- x) == Seq.upd (reveal v) (U32.v i) x)) [SMTPat (v.[i] <- x)] val reveal_append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Lemma (ensures (reveal (v1 @| v2) == Seq.append (reveal v1) (reveal v2))) [SMTPat (v1 @| v2)] val reveal_sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Lemma (ensures (reveal (sub v i j) == S.slice (reveal v) (U32.v i) (U32.v j))) [SMTPat (sub v i j)] //////////////////////////////////////////////////////////////////////////////// /// Now, we have `Vector.Base.t`, abstractly, a raw vector paired with its u32 length //////////////////////////////////////////////////////////////////////////////// val t: a:Type u#a -> Type u#a /// Unlike raw vectors, t-vectors support decidable equality val t_has_eq: a:Type u#a -> Lemma (requires (hasEq a)) (ensures (hasEq (t a))) [SMTPat (hasEq (t a))] /// The length of a t-vector is a dynamically computable u32 val len: #a:Type -> t a -> len_t /// A convenience to access the length of a t-vector as a nat
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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: FStar.Vector.Base.t a -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.t", "FStar.UInt32.v", "FStar.Vector.Base.len", "Prims.nat" ]
[]
false
false
false
true
false
let length (#a: Type) (x: t a) : nat =
U32.v (len x)
false
FStar.Vector.Base.fsti
FStar.Vector.Base.slice
val slice (#a: Type) (x: t a) (i: len_t) (j: len_t{let open U32 in v i <= v j /\ v j <= length x}) : Tot (t a)
val slice (#a: Type) (x: t a) (i: len_t) (j: len_t{let open U32 in v i <= v j /\ v j <= length x}) : Tot (t a)
let slice (#a:Type) (x:t a) (i:len_t) (j:len_t{U32.(v i <= v j /\ v j <= length x)}) : Tot (t a) = from_raw (sub (as_raw x) i j)
{ "file_name": "ulib/FStar.Vector.Base.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 343, "start_col": 0, "start_line": 337 }
(* Copyright 2008-2017 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. *) (* A library for vectors, i.e., immutable arrays, whose length is representable by a machine integer, FStar.UInt32.t. This is closely related to FStar.Seq, with the following main differences: The type `raw a l`: A raw vector 1. Raw vectors receive special treatment during extraction, especially by KaRaMeL, which extracts a vector to a raw C pointer. When extracting to OCaml, a `raw a l` is a `Batteries.Vect t a` 2. The length of a vector is representable in a U32.t 3. The interface is designed around a length-indexed type: this enables the compilation to raw pointers, since this ensures that all functions that manipulate vectors always have a U32 variable describing that vector's length in scope. A length-indexed interface is also suitable for clients for whom proving properties about the length is a primary concern: the signatures in this interface carry intrinsic proofs about length properties, simplifying proof obligations in client code. 4. Raw vectors lack decidable equality (since that cannot be implemented given the representation choice in KaRaMeL) The type `t a`: A dynamically sized vector 1. Conceptually, a `t a` is a pair of a `len:U32.t` and a `raw a len`. They are implemented as such by KaRaMeL. When extracting to OCaml, `t a` is identical to `raw a _`, i.e., it is still extracted to a `Batteries.Vect.t a` 2. Unlike raw vectors, `t a` supports decidable equality when it is supported by `a`. This is the main reason `t a` is provided at an abstract type, rather than being exposed as a pair of a U32 and a raw vector, since the latter does not support decidable equality. @summary Immutable vectors whose length is less than `pow2 32` *) module FStar.Vector.Base module U32 = FStar.UInt32 module S = FStar.Seq //////////////////////////////////////////////////////////////////////////////// /// The basic model of raw vectors as u32-length sequences //////////////////////////////////////////////////////////////////////////////// /// The length of a vector fits in 32 bits let len_t = U32.t /// A raw vector. /// - `vector a n` is extracted to an `a*` in C by KaRaMeL /// - Does not support decidable equality val raw ([@@@strictly_positive] a:Type u#a) (l:len_t) : Type u#a /// A convenience to use `nat` for the length of vector in specs and proofs let raw_length (#a:Type) (#l:len_t) (v:raw a l) : GTot nat = U32.v l (** Abstractly, a `vec a l` is just a sequence whose length is `U32.v l`. `reveal` and `hide` build an isomorphism establishing this **) val reveal: #a:Type -> #l:len_t -> v:raw a l -> GTot (s:S.seq a{S.length s = raw_length v}) val hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> GTot (raw a (U32.uint_to_t (S.length s))) val hide_reveal: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (hide (reveal v) == v)) [SMTPat (reveal v)] val reveal_hide: #a:Type -> s:S.seq a{S.length s < pow2 32} -> Lemma (ensures (reveal (hide s) == s)) [SMTPat (hide s)] /// Extensional equality for vectors let equal (#a:Type) (#l:len_t) (v1:raw a l) (v2:raw a l) = Seq.equal (reveal v1) (reveal v2) /// Extensional equality can be used to prove syntactic equality val extensionality: #a:Type -> #l:len_t -> v1:raw a l -> v2:raw a l -> Lemma (requires (equal v1 v2)) (ensures (v1 == v2)) //////////////////////////////////////////////////////////////////////////////// /// end of the basic model //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// A small set of basic operations on raw vectors, corresponding to the operations /// on sequences. Other operations can be derived from these, as we do for seq. /// -- init, index, update, append, slice //////////////////////////////////////////////////////////////////////////////// /// `index_t v`: is the type of a within-bounds index of `v` let index_t (#a:Type) (#l:len_t) (v:raw a l) = m:len_t{U32.v m < U32.v l} /// `init l contents`: /// initialize an `l`-sized vector using `contents i` for the `i`th element val init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Tot (raw a l) /// `index v i`: get the `i`th element of `v` val index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Tot a /// `v.[i]` is shorthand for `index v i` unfold let op_String_Access #a #l = index #a #l /// `update v i x`: /// - a new vector that differs from `v` only at index `i`, where it contains `x`. /// - Incurs a full copy in KaRaMeL /// - In OCaml, the new vector shares as much as possible with `v` val update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Tot (raw a l) /// `v.[i] <- x` is shorthand for `update v i x` unfold let op_String_Assignment #a #l = update #a #l /// `append v1 v2`: /// - requires proving that the sum of the lengths of v1 and v2 still fit in a u32 /// - Incurs a full copy in KaRaMeL /// - Amortized constant time in OCaml val append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Tot (raw a U32.(l1 +^ l2)) /// `v1 @| v2`: shorthand for `append v1 v2` unfold let (@|) #a #l1 #l2 = append #a #l1 #l2 /// `sub v i j`: /// - the sub-vector of `v` starting from index `i` up to, but not including, `j` /// - Constant time in KaRaMeL (just an addition on a pointer) /// - Worst-case (log l) time in OCaml val sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Tot (raw a U32.(j -^ i)) //////////////////////////////////////////////////////////////////////////////// /// Lemmas about the basic operations, all rather boring /// -- Each is just a lifting specifying the corresponding operation on seq //////////////////////////////////////////////////////////////////////////////// val reveal_init: #a:Type -> l:len_t -> contents: (i:nat { i < U32.v l } -> Tot a) -> Lemma (ensures (reveal (init l contents) == Seq.init (U32.v l) contents)) [SMTPat (init l contents)] val reveal_index: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> Lemma (ensures (v.[i] == Seq.index (reveal v) (U32.v i))) [SMTPat (v.[i])] val reveal_update: #a:Type -> #l:len_t -> v:raw a l -> i:index_t v -> x:a -> Lemma (ensures (reveal (v.[i] <- x) == Seq.upd (reveal v) (U32.v i) x)) [SMTPat (v.[i] <- x)] val reveal_append: #a:Type -> #l1:len_t -> #l2:len_t -> v1:raw a l1 -> v2:raw a l2{UInt.size U32.(v l1 + v l2) U32.n} -> Lemma (ensures (reveal (v1 @| v2) == Seq.append (reveal v1) (reveal v2))) [SMTPat (v1 @| v2)] val reveal_sub: #a:Type -> #l:len_t -> v:raw a l -> i:len_t -> j:len_t{U32.(v i <= v j /\ v j <= v l)} -> Lemma (ensures (reveal (sub v i j) == S.slice (reveal v) (U32.v i) (U32.v j))) [SMTPat (sub v i j)] //////////////////////////////////////////////////////////////////////////////// /// Now, we have `Vector.Base.t`, abstractly, a raw vector paired with its u32 length //////////////////////////////////////////////////////////////////////////////// val t: a:Type u#a -> Type u#a /// Unlike raw vectors, t-vectors support decidable equality val t_has_eq: a:Type u#a -> Lemma (requires (hasEq a)) (ensures (hasEq (t a))) [SMTPat (hasEq (t a))] /// The length of a t-vector is a dynamically computable u32 val len: #a:Type -> t a -> len_t /// A convenience to access the length of a t-vector as a nat [@@"deprecated: this will be moved to the ghost effect"] let length (#a:Type) (x:t a) : nat = U32.v (len x) /// Access the underlying raw vector val as_raw: #a:Type -> x:t a -> raw a (len x) /// Promote a raw vector val from_raw: #a:Type -> #l:len_t -> v:raw a l -> x:t a{len x = l} /// as_raw and from_raw are mutual inverses val as_raw_from_raw: #a:Type -> #l:len_t -> v:raw a l -> Lemma (ensures (as_raw (from_raw v) == v)) [SMTPat (from_raw v)] val from_raw_as_raw: #a:Type -> x:t a -> Lemma (ensures (from_raw (as_raw x) == x)) [SMTPat (as_raw x)] /// `v.(i)` accesses the ith element of v unfold let op_Array_Access (#a:Type) (x:t a) (i:index_t (as_raw x)) : Tot a = (as_raw x).[i] /// `v.(i) <- x` is a new t-vector that differs from v only at i unfold let op_Array_Assignment (#a:Type) (x:t a) (i:index_t (as_raw x)) (v:a) : Tot (t a) = from_raw ((as_raw x).[i] <- v) /// `v1 @@ v2`: appending t-vectors unfold let (@@) (#a:Type) (x1:t a) (x2:t a{UInt.size (length x1 + length x2) U32.n}) : Tot (t a) = from_raw (as_raw x1 @| as_raw x2) /// `slice v i j`: /// the sub-vector of `v` starting from index `i` up to, but not including, `j`
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Vector.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Vector", "short_module": null }, { "abbrev": 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: FStar.Vector.Base.t a -> i: FStar.Vector.Base.len_t -> j: FStar.Vector.Base.len_t {FStar.UInt32.v i <= FStar.UInt32.v j /\ FStar.UInt32.v j <= FStar.Vector.Base.length x} -> FStar.Vector.Base.t a
Prims.Tot
[ "total" ]
[]
[ "FStar.Vector.Base.t", "FStar.Vector.Base.len_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "FStar.Vector.Base.length", "FStar.Vector.Base.from_raw", "FStar.UInt32.op_Subtraction_Hat", "FStar.Vector.Base.sub", "FStar.Vector.Base.len", "FStar.Vector.Base.as_raw" ]
[]
false
false
false
false
false
let slice (#a: Type) (x: t a) (i: len_t) (j: len_t{let open U32 in v i <= v j /\ v j <= length x}) : Tot (t a) =
from_raw (sub (as_raw x) i j)
false
LList.Invariant.fst
LList.Invariant.llist'
val llist' (#a: Type) (ptr: t a) (l: list (cell a)) : Tot vprop (decreases l)
val llist' (#a: Type) (ptr: t a) (l: list (cell a)) : Tot vprop (decreases l)
let rec llist' (#a:Type) (ptr:t a) (l:list (cell a)) : Tot vprop (decreases l) = match l with | [] -> pure (ptr == null_llist) | hd :: tl -> pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star` llist' (next hd) tl
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 25, "end_line": 62, "start_col": 0, "start_line": 51 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d } let hd l = Cons?.hd l let tl l = Cons?.tl l let null_llist (#a:Type) = null let ptr_eq (#a:Type) (x y:t a) = admit() //////////////////////////////////////////////////////////////////////////////// // Main llist invariant
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
ptr: LList.Invariant.t a -> l: Prims.list (LList.Invariant.cell a) -> Prims.Tot Steel.Effect.Common.vprop
Prims.Tot
[ "total", "" ]
[]
[ "LList.Invariant.t", "Prims.list", "LList.Invariant.cell", "Steel.Effect.Common.pure", "Prims.eq2", "LList.Invariant.null_llist", "Steel.Effect.Common.star", "Prims.l_not", "Steel.Reference.pts_to", "Steel.FractionalPermission.full_perm", "LList.Invariant.llist'", "LList.Invariant.next", "Steel.Effect.Common.vprop" ]
[ "recursion" ]
false
false
false
true
false
let rec llist' (#a: Type) (ptr: t a) (l: list (cell a)) : Tot vprop (decreases l) =
match l with | [] -> pure (ptr == null_llist) | hd :: tl -> ((pure (ptr =!= null_llist)) `star` (pts_to ptr full_perm hd)) `star` (llist' (next hd) tl)
false
Vale.X64.Memory_Sems.fst
Vale.X64.Memory_Sems.low_lemma_store_mem128_hi64_full
val low_lemma_store_mem128_hi64_full (b:buffer128) (i:nat) (v:nat64) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let ptr = buffer_addr b h + scale16 i + 8 in let v' = insert_nat64 (buffer_read b i h) v 1 in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ is_full_update vfh (buffer_write b i v' h) hid (S.update_heap64 ptr v (heap_get (coerce vfh))) (S.update_n ptr 8 (heap_taint (coerce vfh)) t) ))
val low_lemma_store_mem128_hi64_full (b:buffer128) (i:nat) (v:nat64) (vfh:vale_full_heap) (t:taint) (hid:heaplet_id) : Lemma (requires ( let (h, mt) = (Map16.get vfh.vf_heaplets hid, vfh.vf_layout.vl_taint) in i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b /\ buffer_writeable b /\ valid_layout_buffer b vfh.vf_layout h true /\ valid_taint_buf128 b h mt t /\ mem_inv vfh )) (ensures ( let h = Map16.get vfh.vf_heaplets hid in let ptr = buffer_addr b h + scale16 i + 8 in let v' = insert_nat64 (buffer_read b i h) v 1 in buffer_addr b vfh.vf_heap == buffer_addr b h /\ valid_addr64 ptr (heap_get (coerce vfh)) /\ is_full_update vfh (buffer_write b i v' h) hid (S.update_heap64 ptr v (heap_get (coerce vfh))) (S.update_n ptr 8 (heap_taint (coerce vfh)) t) ))
let low_lemma_store_mem128_hi64_full b i v vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let v' = insert_nat64 (buffer_read b i h) v 1 in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v' (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v' hk in let mhk' = S.update_heap128 ptr v' (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v' h; low_lemma_store_mem128 b i v' (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v' h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v' hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v' t; low_lemma_store_mem128_hi64 b i v h; low_lemma_valid_mem128_64 b i h; assert (Map.equal mt (S.update_n (buffer_addr b h + 16 * i + 8) 8 mt t)); ()
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 1145, "start_col": 0, "start_line": 1125 }
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Words_s module I = Vale.Interop module S = Vale.X64.Machine_Semantics_s module MB = LowStar.Monotonic.Buffer module UV = LowStar.BufferView.Up module DV = LowStar.BufferView.Down open Vale.Lib.BufferViewHelpers open Vale.Arch.HeapImpl open Vale.Arch.Heap friend Vale.X64.Memory module IB = Vale.Interop.Base let same_domain h m = Set.equal (IB.addrs_set (_ih h)) (Map.domain m) let lemma_same_domains h m1 m2 = () let get_heap h = I.down_mem (_ih h) let upd_heap h m = mi_heap_upd h m //let lemma_upd_get_heap h = I.down_up_identity (_ih h) let lemma_get_upd_heap h m = I.up_down_identity (_ih h) m let lemma_heap_impl = () let lemma_heap_get_heap h = () let lemma_heap_taint h = () //let lemma_heap_upd_heap h mh mt = () [@"opaque_to_smt"] let rec set_of_range (a:int) (n:nat) : Pure (Set.set int) (requires True) (ensures fun s -> (forall (i:int).{:pattern Set.mem i s} Set.mem i s <==> a <= i /\ i < a + n)) = if n = 0 then Set.empty else Set.union (set_of_range a (n - 1)) (Set.singleton (a + n - 1)) let buffer_info_has_addr (bi:buffer_info) (a:int) = let b = bi.bi_buffer in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in addr <= a /\ a < addr + len let buffer_info_has_addr_opt (bi:option buffer_info) (a:int) = match bi with | None -> False | Some bi -> buffer_info_has_addr bi a #set-options "--z3rlimit 100" let rec make_owns_rec (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = if n = 0 then ((fun _ -> None), (fun _ -> Set.empty)) else let (m0, s0) = make_owns_rec h bs (n - 1) in let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let s i = if i = hi then Set.union (s0 i) s_b else s0 i in let m a = if addr <= a && a < addr + len then Some (n - 1) else m0 a in (m, s) [@"opaque_to_smt"] let make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat{n <= Seq.length bs}) : GTot ((int -> option (n:nat{n < Seq.length bs})) & (heaplet_id -> Set.set int)) = make_owns_rec h bs n let rec lemma_make_owns (h:vale_heap) (bs:Seq.seq buffer_info) (n:nat) : Lemma (requires n <= Seq.length bs /\ (forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> buffer_readable h (Seq.index bs i).bi_buffer) /\ (forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)} i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) ) (ensures ( let (m, s) = make_owns h bs n in (forall (i:heaplet_id) (a:int).{:pattern Set.mem a (s i)} (Set.mem a (s i) <==> Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (m a) == Some i) /\ (Set.mem a (s i) ==> buffer_info_has_addr_opt (Option.mapTot (fun n -> Seq.index bs n) (m a)) a) /\ (Set.mem a (s i) ==> Set.mem a (Map.domain h.mh)) ) /\ (forall (k:nat) (a:int).{:pattern Set.mem a (s (Seq.index bs k).bi_heaplet)} k < n /\ buffer_info_has_addr (Seq.index bs k) a ==> Set.mem a (s (Seq.index bs k).bi_heaplet)) )) = reveal_opaque (`%make_owns) make_owns; if n = 0 then () else let _ = make_owns h bs (n - 1) in let (m, s) = make_owns h bs n in lemma_make_owns h bs (n - 1); let bi = Seq.index bs (n - 1) in let b = bi.bi_buffer in let hi = bi.bi_heaplet in let addr = Vale.Interop.Heap_s.global_addrs_map b in let len = DV.length (get_downview b.bsrc) in let s_b = set_of_range addr len in let lem1 (a:int) : Lemma (requires Set.mem a s_b) (ensures Set.mem a (Map.domain h.mh)) [SMTPat (Set.mem a (Map.domain h.mh))] = I.addrs_set_mem h.ih b a in let lem2 (i:heaplet_id) (a:int) : Lemma (requires i =!= hi /\ Set.mem a (Set.intersect s_b (s i))) (ensures False) [SMTPat (Set.mem a (s i))] = reveal_opaque (`%addr_map_pred) addr_map_pred in () #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 2 --max_ifuel 2" let rec lemma_loc_mutable_buffers_rec (l:list buffer_info) (s:Seq.seq buffer_info) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ list_to_seq_post l s n ) (ensures ( let modloc = loc_mutable_buffers l in forall (i:nat).{:pattern Seq.index s i} n <= i /\ i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer bi.bi_buffer)) )) (decreases l) = match l with | [] -> () | h::t -> lemma_loc_mutable_buffers_rec t s (n + 1) #pop-options let lemma_loc_mutable_buffers (l:list buffer_info) : Lemma (ensures ( let s = list_to_seq l in forall (i:nat).{:pattern Seq.index s i} i < Seq.length s ==> ( let bi = Seq.index s i in bi.bi_mutable == Mutable ==> loc_includes (loc_mutable_buffers l) (loc_buffer bi.bi_buffer)) )) = lemma_list_to_seq l; lemma_loc_mutable_buffers_rec l (list_to_seq l) 0 let create_heaplets buffers h1 = let bs = list_to_seq buffers in let modloc = loc_mutable_buffers buffers in let layout1 = h1.vf_layout in let layin1 = layout1.vl_inner in let (hmap, hsets) = make_owns h1.vf_heap bs (Seq.length bs) in let hmap a = Option.mapTot (fun n -> (Seq.index bs n).bi_heaplet) (hmap a) in let l = { vl_heaplets_initialized = true; vl_heaplet_map = hmap; vl_heaplet_sets = hsets; vl_old_heap = h1.vf_heap; vl_buffers = bs; vl_mod_loc = modloc; } in let layout2 = {layout1 with vl_inner = l} in let h2 = { vf_layout = layout2; vf_heap = h1.vf_heap; vf_heaplets = h1.vf_heaplets; } in h2 let lemma_create_heaplets buffers h1 = let bs = list_to_seq buffers in let h2 = create_heaplets buffers h1 in assert (h2.vf_layout.vl_inner.vl_buffers == bs); // REVIEW: why is this necessary, even with extra ifuel? lemma_make_owns h1.vf_heap bs (Seq.length bs); lemma_loc_mutable_buffers buffers; reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let destroy_heaplets h1 = h1 let lemma_destroy_heaplets h1 = () val heap_shift (m1 m2:S.machine_heap) (base:int) (n:nat) : Lemma (requires (forall i. 0 <= i /\ i < n ==> m1.[base + i] == m2.[base + i])) (ensures (forall i. {:pattern (m1.[i])} base <= i /\ i < base + n ==> m1.[i] == m2.[i])) #push-options "--smtencoding.l_arith_repr boxwrap" let heap_shift m1 m2 base n = assert (forall i. base <= i /\ i < base + n ==> m1.[base + (i - base)] == m2.[base + (i - base)]) #pop-options val same_mem_eq_slices64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 8 + 8 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 8) (k * 8 + 8))) let same_mem_eq_slices64 b i v k h1 h2 mem1 mem2 = let t = TUInt64 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up64 (b:buffer64) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 8}) : Lemma (scale8 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint64_view in UV.length_eq vb val same_mem_get_heap_val64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1))}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale8 k in forall (x:int).{:pattern (mem1.[x])} ptr <= x /\ x < ptr + 8 ==> mem1.[x] == mem2.[x])) let same_mem_get_heap_val64 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale8 k in let addr = buffer_addr b h1 in let aux (x:int{ptr <= x /\ x < ptr + 8}) : Lemma (mem1.[x] == mem2.[x]) = let i = x - ptr in let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint64_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices64 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8) (k * 8 + 8)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8) (k * 8 + 8)) in assert (Seq.index s1 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i)); length_up64 b h1 k i; assert (mem1.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 8 + i))); assert (Seq.index s2 i == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i)); length_up64 b h2 k i; assert (mem2.[addr+(scale8 k + i)] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 8 + i))) in Classical.forall_intro aux; assert (forall i. addr + (scale8 k + i) == ptr + i) let rec written_buffer_down64_aux1 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale8 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux1 b i v h base (k+1) h1 mem1 mem2 end let rec written_buffer_down64_aux2 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale8 (i+1) <= j /\ j < base + k * 8 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale8 (i+1) /\ j < base + scale8 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale8 k in same_mem_get_heap_val64 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 8; written_buffer_down64_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down64 (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap) : Lemma (requires List.memP b (IB.ptrs_of_mem (_ih h))) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale8 i) \/ (base + scale8 (i+1) <= j /\ j < base + scale8 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down64_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down64_aux2 b i v h base n (i+1) h1 mem1 mem2 let unwritten_buffer_down (t:base_typ) (b:buffer t{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:base_typ_as_vale_type t) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall (a:b8{List.memP a (IB.ptrs_of_mem (_ih h)) /\ a =!= b}) j. {:pattern mem1.[j]; List.memP a (IB.ptrs_of_mem (_ih h)) \/ mem2.[j]; List.memP a (IB.ptrs_of_mem (_ih h))} let base = (IB.addrs_of_mem (_ih h)) a in j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let aux (a:b8{a =!= b /\ List.memP a (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let base = (IB.addrs_of_mem (_ih h)) a in let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in forall j. j >= base /\ j < base + DV.length (get_downview a.bsrc) ==> mem1.[j] == mem2.[j])) = let db = get_downview a.bsrc in if DV.length db = 0 then () else let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = (IB.addrs_of_mem (_ih h)) a in let s0 = DV.as_seq (IB.hs_of_mem (_ih h)) db in let s1 = DV.as_seq (IB.hs_of_mem (_ih h1)) db in opaque_assert (`%IB.list_disjoint_or_eq) IB.list_disjoint_or_eq IB.list_disjoint_or_eq_def (MB.disjoint a.bsrc b.bsrc); lemma_dv_equal (IB.down_view a.src) a.bsrc (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)); assert (Seq.equal s0 s1); assert (forall (j:int).{:pattern (mem1.[j])} base <= j /\ j < base + Seq.length s0 ==> v_to_typ TUInt8 (Seq.index s0 (j - base)) == mem1.[j]); heap_shift mem1 mem2 base (DV.length db) in Classical.forall_intro aux let store_buffer_down64_mem (b:buffer64{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h))}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale8 i \/ j >= base + scale8 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down64 b i v h; length_t_eq (TUInt64) b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (IB.hs_of_mem (_ih h)) (IB.hs_of_mem (_ih h1)) (IB.ptrs_of_mem (_ih h)) else unwritten_buffer_down TUInt64 b i v h in Classical.forall_intro aux let store_buffer_aux_down64_mem (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 8 ==> mem1.[j] == mem2.[j])) = let t = TUInt64 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale8 i == ptr); assert (buffer_addr b h + scale8 (i+1) == ptr + 8); store_buffer_down64_mem b i v h let store_buffer_aux_down64_mem2 (ptr:int) (v:nat64) (h:vale_heap{writeable_mem64 ptr h}) : Lemma (ensures ( let h1 = store_mem (TUInt64) ptr v h in let mem2 = I.down_mem (_ih h1) in S.get_heap_val64 ptr mem2 == v)) = let t = TUInt64 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index64_get_heap_val64 h1 b mem2 i let in_bounds64 (h:vale_heap) (b:buffer64) (i:nat{i < buffer_length b}) : Lemma (scale8 i + 8 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt64 b let bytes_valid64 ptr h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds64 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7) val same_mem_get_heap_val128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures (let ptr = buffer_addr b h1 + scale16 k in forall i.{:pattern mem1.[i]} i >= ptr /\ i < ptr+16 ==> mem1.[i] == mem2.[i])) val same_mem_eq_slices128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (k:nat{k < buffer_length b}) (h1:vale_heap{List.memP b (IB.ptrs_of_mem (_ih h1)) /\ buffer_writeable b}) (h2:vale_heap{h2 == buffer_write b i v h1}) (mem1:S.machine_heap{IB.correct_down_p (_ih h1) mem1 b}) (mem2:S.machine_heap{IB.correct_down_p (_ih h2) mem2 b}) : Lemma (requires (Seq.index (buffer_as_seq h1 b) k == Seq.index (buffer_as_seq h2 b) k)) (ensures ( k * 16 + 16 <= DV.length (get_downview b.bsrc) /\ Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16) == Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) (get_downview b.bsrc)) (k * 16) (k * 16 + 16))) let same_mem_eq_slices128 b i v k h1 h2 mem1 mem2 = let t = TUInt128 in let db = get_downview b.bsrc in let ub = UV.mk_buffer db (uint_view t) in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; UV.put_sel (IB.hs_of_mem (_ih h1)) ub k; UV.put_sel (IB.hs_of_mem (_ih h2)) ub k; UV.length_eq ub let length_up128 (b:buffer128) (h:vale_heap) (k:nat{k < buffer_length b}) (i:nat{i < 16}) : Lemma (scale16 k + i <= DV.length (get_downview b.bsrc)) = let vb = UV.mk_buffer (get_downview b.bsrc) uint128_view in UV.length_eq vb let same_mem_get_heap_val128 b j v k h1 h2 mem1 mem2 = let ptr = buffer_addr b h1 + scale16 k in let addr = buffer_addr b h1 in let aux (i:nat{ptr <= i /\ i < ptr+16}) : Lemma (mem1.[i] == mem2.[i]) = let db = get_downview b.bsrc in let ub = UV.mk_buffer db uint128_view in UV.as_seq_sel (IB.hs_of_mem (_ih h1)) ub k; UV.as_seq_sel (IB.hs_of_mem (_ih h2)) ub k; same_mem_eq_slices128 b j v k h1 h2 mem1 mem2; let s1 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16) (k * 16 + 16)) in let s2 = (Seq.slice (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16) (k * 16 + 16)) in assert (Seq.index s1 (i - ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr))); length_up128 b h1 k (i-ptr); assert (mem1.[i] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h1)) db) (k * 16 + (i-ptr)))); assert (Seq.index s2 (i-ptr) == Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr))); length_up128 b h2 k (i-ptr); assert (mem2.[addr+(scale16 k + (i-ptr))] == UInt8.v (Seq.index (DV.as_seq (IB.hs_of_mem (_ih h2)) db) (k * 16 + (i-ptr)))); assert (forall i. addr + (scale16 k + (i-ptr)) == i) in Classical.forall_intro aux let in_bounds128 (h:vale_heap) (b:buffer128) (i:nat{i < buffer_length b}) : Lemma (scale16 i + 16 <= DV.length (get_downview b.bsrc)) = length_t_eq TUInt128 b #push-options "--z3rlimit 20" #restart-solver let bytes_valid128 ptr h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; IB.list_disjoint_or_eq_reveal (); let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in in_bounds128 h b i; I.addrs_set_mem (_ih h) b ptr; I.addrs_set_mem (_ih h) b (ptr+1); I.addrs_set_mem (_ih h) b (ptr+2); I.addrs_set_mem (_ih h) b (ptr+3); I.addrs_set_mem (_ih h) b (ptr+4); I.addrs_set_mem (_ih h) b (ptr+5); I.addrs_set_mem (_ih h) b (ptr+6); I.addrs_set_mem (_ih h) b (ptr+7); I.addrs_set_mem (_ih h) b (ptr+8); I.addrs_set_mem (_ih h) b (ptr+9); I.addrs_set_mem (_ih h) b (ptr+10); I.addrs_set_mem (_ih h) b (ptr+11); I.addrs_set_mem (_ih h) b (ptr+12); I.addrs_set_mem (_ih h) b (ptr+13); I.addrs_set_mem (_ih h) b (ptr+14); I.addrs_set_mem (_ih h) b (ptr+15) #pop-options let equiv_load_mem64 ptr h = let t = TUInt64 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in index64_get_heap_val64 h b heap i; lemma_load_mem64 b i h //let low_lemma_valid_mem64 b i h = // lemma_valid_mem64 b i h; // bytes_valid64 (buffer_addr b h + scale8 i) h //let low_lemma_load_mem64 b i h = // lemma_valid_mem64 b i h; // lemma_load_mem64 b i h; // equiv_load_mem64 (buffer_addr b h + scale8 i) h //let same_domain_update64 b i v h = // low_lemma_valid_mem64 b i h; // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale8 i) v (get_heap h) open Vale.X64.BufferViewStore let low_lemma_store_mem64_aux (b:buffer64) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:nat64) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in let h' = store_mem64 (buffer_addr b h + scale8 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale8 i in let heap' = S.update_heap64 ptr v heap in let h' = store_mem64 ptr v h in lemma_store_mem64 b i v h; length_t_eq TUInt64 b; bv_upd_update_heap64 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view64 in assert (UV.upd (_ih h).IB.hs bv i (UInt64.uint_to_t v) == (_ih h').IB.hs) val valid_state_store_mem64_aux: (i:nat) -> (v:nat64) -> (h:vale_heap) -> Lemma (requires writeable_mem64 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h' = store_mem64 i v h in heap' == I.down_mem (_ih h') )) let valid_state_store_mem64_aux i v h = let heap = get_heap h in let heap' = S.update_heap64 i v heap in let h1 = store_mem TUInt64 i v h in store_buffer_aux_down64_mem i v h; store_buffer_aux_down64_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.same_mem_get_heap_val64 i mem1 mem2; Vale.Arch.MachineHeap.correct_update_get64 i v heap; Vale.Arch.MachineHeap.frame_update_heap64 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid64 i h; Vale.Arch.MachineHeap.same_domain_update64 i v heap in aux(); aux2(); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem64_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () #push-options "--z3rlimit 20" #restart-solver let low_lemma_store_mem64 b i v h = lemma_writeable_mem64 b i h; lemma_store_mem64 b i v h; valid_state_store_mem64_aux (buffer_addr b h + scale8 i) v h; let heap = get_heap h in let heap' = S.update_heap64 (buffer_addr b h + scale8 i) v heap in low_lemma_store_mem64_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap64 (buffer_addr b h + scale8 i) v heap; in_bounds64 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' #pop-options #set-options "--z3rlimit 100" #restart-solver let lemma_is_full_update (vfh:vale_full_heap) (h hk hk':vale_heap) (k:heaplet_id) (mh mh' mhk mhk':machine_heap) (mt mt':memtaint) (t:base_typ) (b:buffer t) (ptr:int) (v_size:nat) (index:nat) (v:base_typ_as_vale_type t) (tn:taint) : Lemma (requires vfh.vf_layout.vl_inner.vl_heaplets_initialized /\ mem_inv vfh /\ buffer_readable hk b /\ buffer_writeable b /\ index < Seq.length (buffer_as_seq hk b) /\ mt == vfh.vf_layout.vl_taint /\ h == vfh.vf_heap /\ hk == Map16.sel vfh.vf_heaplets k /\ mh == h.mh /\ mhk == hk.mh /\ ptr == buffer_addr b hk + scale_by v_size index /\ mt' == S.update_n ptr v_size (heap_taint (coerce vfh)) tn /\ hk' == buffer_write b index v hk /\ valid_layout_buffer b vfh.vf_layout hk true /\ valid_taint_buf b hk mt tn /\ is_machine_heap_update mh mh' /\ upd_heap h mh' == buffer_write b index v h /\ is_machine_heap_update mhk mhk' /\ upd_heap hk mhk' == buffer_write b index v hk /\ (forall j.{:pattern mh.[j] \/ mh'.[j]} j < ptr \/ j >= ptr + v_size ==> mh.[j] == mh'.[j]) /\ (forall j.{:pattern mhk.[j] \/ mhk'.[j]} j < ptr \/ j >= ptr + v_size ==> mhk.[j] == mhk'.[j]) /\ 0 <= scale_by v_size index /\ scale_by v_size index + v_size <= DV.length (get_downview b.bsrc) /\ (forall i.{:pattern mh'.[i] \/ mhk'.[i]} i >= ptr /\ i < ptr + v_size ==> mh'.[i] == mhk'.[i]) /\ True ) (ensures is_full_update vfh hk' k mh' mt') = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in let dom_upd = Set.intersect (vfh.vf_layout.vl_inner.vl_heaplet_sets k) (Map.domain mhk) in let mhk'' = Map.concat mhk (Map.restrict dom_upd mh') in assert (Map.equal mhk'' mhk'); let unchanged (j:heaplet_id) : Lemma (requires j =!= k) (ensures Map16.sel vfh'.vf_heaplets j == Map16.sel vfh.vf_heaplets j) [SMTPat (Map16.sel vfh'.vf_heaplets j)] = assert (Map.equal (Map16.sel vfh'.vf_heaplets j).mh (Map16.sel vfh.vf_heaplets j).mh); I.down_up_identity (Map16.sel vfh.vf_heaplets j).ih; () in assert (Map16.equal vfh'.vf_heaplets (Map16.upd vfh.vf_heaplets k hk')); assert (Map.equal mt' mt); Vale.Interop.Heap_s.list_disjoint_or_eq_reveal (); () let low_lemma_store_mem64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale8 i in let mh' = S.update_heap64 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 8 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap64 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem64 b i v h; low_lemma_store_mem64 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap64 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap64 ptr v hk.mh; in_bounds64 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val64 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt64 b ptr 8 i v t; () val low_lemma_valid_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.valid_addr128 (buffer_addr b h + scale16 i) (get_heap h) ) let low_lemma_valid_mem128 b i h = lemma_valid_mem128 b i h; bytes_valid128 (buffer_addr b h + scale16 i) h val equiv_load_mem128_aux: (ptr:int) -> (h:vale_heap) -> Lemma (requires valid_mem128 ptr h) (ensures load_mem128 ptr h == S.get_heap_val128 ptr (get_heap h)) let equiv_load_mem128_aux ptr h = let t = TUInt128 in let b = get_addr_ptr t ptr h in let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let addr = buffer_addr b h in let contents = DV.as_seq (_ih h).IB.hs (get_downview b.bsrc) in let heap = get_heap h in S.get_heap_val128_reveal (); index128_get_heap_val128 h b heap i; lemma_load_mem128 b i h let equiv_load_mem128 ptr h = equiv_load_mem128_aux ptr h val low_lemma_load_mem128 (b:buffer128) (i:nat) (h:vale_heap) : Lemma (requires i < Seq.length (buffer_as_seq h b) /\ buffer_readable h b ) (ensures S.get_heap_val128 (buffer_addr b h + scale16 i) (get_heap h) == buffer_read b i h ) let low_lemma_load_mem128 b i h = lemma_valid_mem128 b i h; lemma_load_mem128 b i h; equiv_load_mem128_aux (buffer_addr b h + scale16 i) h //let same_domain_update128 b i v h = // low_lemma_valid_mem128 b i h; // Vale.Arch.MachineHeap.same_domain_update128 (buffer_addr b h + scale16 i) v (get_heap h) let low_lemma_store_mem128_aux (b:buffer128) (heap:S.machine_heap) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{buffer_readable h b /\ buffer_writeable b}) : Lemma (requires IB.correct_down_p (_ih h) heap b) (ensures (let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in (_ih h').IB.hs == DV.upd_seq (_ih h).IB.hs (get_downview b.bsrc) (I.get_seq_heap heap' (_ih h).IB.addrs b))) = let ptr = buffer_addr b h + scale16 i in let heap' = S.update_heap128 ptr v heap in let h' = store_mem128 ptr v h in lemma_store_mem128 b i v h; length_t_eq TUInt128 b; bv_upd_update_heap128 b heap i v (_ih h); let db = get_downview b.bsrc in let bv = UV.mk_buffer db Vale.Interop.Views.up_view128 in assert (UV.upd (_ih h).IB.hs bv i v == (_ih h').IB.hs) val valid_state_store_mem128_aux (i:int) (v:quad32) (h:vale_heap) : Lemma (requires writeable_mem128 i h) (ensures ( let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h' = store_mem128 i v h in heap' == I.down_mem (_ih h') )) #restart-solver let rec written_buffer_down128_aux1 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (k:nat) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j.{:pattern (mem1.[j]) \/ (mem2.[j])} base <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem1.[j])} j >= base /\ j < base + scale16 i ==> mem1.[j] == mem2.[j])) (decreases %[i-k]) = if k >= i then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux1 b i v h base (k+1) h1 mem1 mem2 end #restart-solver let rec written_buffer_down128_aux2 (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) (base:nat{base == buffer_addr b h}) (n:nat{n == buffer_length b}) (k:nat{k > i}) (h1:vale_heap{h1 == buffer_write b i v h}) (mem1:S.machine_heap{IB.correct_down (_ih h) mem1}) (mem2:S.machine_heap{IB.correct_down (_ih h1) mem2 /\ (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} base + scale16 (i+1) <= j /\ j < base + k * 16 ==> mem1.[j] == mem2.[j])}) : Lemma (ensures (forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} j >= base + scale16 (i+1) /\ j < base + scale16 n ==> mem1.[j] == mem2.[j])) (decreases %[n-k]) = if k >= n then () else begin let ptr = base + scale16 k in same_mem_get_heap_val128 b i v k h h1 mem1 mem2; heap_shift mem1 mem2 ptr 16; written_buffer_down128_aux2 b i v h base n (k+1) h1 mem1 mem2 end let written_buffer_down128 (b:buffer128) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap) : Lemma (requires List.memP b (_ih h).IB.ptrs /\ buffer_writeable b) (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in forall j. {:pattern (mem1.[j]) \/ (mem2.[j])} (base <= j /\ j < base + scale16 i) \/ (base + scale16 (i+1) <= j /\ j < base + scale16 n) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in written_buffer_down128_aux1 b i v h base 0 h1 mem1 mem2; written_buffer_down128_aux2 b i v h base n (i+1) h1 mem1 mem2 let store_buffer_down128_mem (b:buffer128{buffer_writeable b}) (i:nat{i < buffer_length b}) (v:quad32) (h:vale_heap{List.memP b (_ih h).IB.ptrs}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in forall (j:int). {:pattern mem1.[j] \/ mem2.[j]} j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j])) = let mem1 = I.down_mem (_ih h) in let h1 = buffer_write b i v h in let mem2 = I.down_mem (_ih h1) in let base = buffer_addr b h in let n = buffer_length b in let aux (j:int) : Lemma (j < base + scale16 i \/ j >= base + scale16 (i+1) ==> mem1.[j] == mem2.[j]) = I.addrs_set_lemma_all (); if j >= base && j < base + DV.length (get_downview b.bsrc) then begin written_buffer_down128 b i v h; length_t_eq TUInt128 b end else if not (I.valid_addr (_ih h) j) then I.same_unspecified_down (_ih h).IB.hs (_ih h1).IB.hs (_ih h).IB.ptrs else unwritten_buffer_down TUInt128 b i v h in Classical.forall_intro aux let store_buffer_aux_down128_mem (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let mem1 = I.down_mem (_ih h) in let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in forall j. {:pattern mem1.[j] \/ mem2.[j]} j < ptr \/ j >= ptr + 16 ==> mem1.[j] == mem2.[j])) = let t = TUInt128 in let h1 = store_mem t ptr v h in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in store_buffer_write t ptr v h; assert (buffer_addr b h + scale16 i == ptr); assert (buffer_addr b h + scale16 (i+1) == ptr + 16); store_buffer_down128_mem b i v h let store_buffer_aux_down128_mem2 (ptr:int) (v:quad32) (h:vale_heap{writeable_mem128 ptr h}) : Lemma (ensures ( let h1 = store_mem TUInt128 ptr v h in let mem2 = I.down_mem (_ih h1) in Mkfour (S.get_heap_val32 ptr mem2) (S.get_heap_val32 (ptr+4) mem2) (S.get_heap_val32 (ptr+8) mem2) (S.get_heap_val32 (ptr+12) mem2) == v)) = let t = TUInt128 in let b = Some?.v (find_writeable_buffer t ptr h) in length_t_eq t b; let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in let h1 = store_mem t ptr v h in let mem2 = I.down_mem (_ih h1) in store_buffer_write t ptr v h; assert (Seq.index (buffer_as_seq h1 b) i == v); index128_get_heap_val128 h1 b mem2 i let valid_state_store_mem128_aux i v h = let heap = get_heap h in let heap' = S.update_heap128 i v heap in let h1 = store_mem TUInt128 i v h in store_buffer_aux_down128_mem i v h; store_buffer_aux_down128_mem2 i v h; let mem1 = heap' in let mem2 = I.down_mem (_ih h1) in let aux () : Lemma (forall j. mem1.[j] == mem2.[j]) = Vale.Arch.MachineHeap.correct_update_get128 i v heap; Vale.X64.Machine_Semantics_s.get_heap_val128_reveal (); Vale.Arch.MachineHeap.same_mem_get_heap_val32 i mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+4) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+8) mem1 mem2; Vale.Arch.MachineHeap.same_mem_get_heap_val32 (i+12) mem1 mem2; Vale.Arch.MachineHeap.frame_update_heap128 i v heap in let aux2 () : Lemma (Set.equal (Map.domain mem1) (Map.domain mem2)) = bytes_valid128 i h; Vale.Arch.MachineHeap.same_domain_update128 i v heap in aux (); aux2 (); Map.lemma_equal_intro mem1 mem2 let low_lemma_load_mem128_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; () let low_lemma_store_mem128 b i v h = lemma_valid_mem128 b i h; lemma_store_mem128 b i v h; valid_state_store_mem128_aux (buffer_addr b h + scale16 i) v h; let heap = get_heap h in let heap' = S.update_heap128 (buffer_addr b h + scale16 i) v heap in let h' = store_mem128 (buffer_addr b h + scale16 i) v h in low_lemma_store_mem128_aux b heap i v h; Vale.Arch.MachineHeap.frame_update_heap128 (buffer_addr b h + scale16 i) v heap; in_bounds128 h b i; I.addrs_set_lemma_all (); I.update_buffer_up_mem (_ih h) b heap heap' let low_lemma_store_mem128_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v hk in let mhk' = S.update_heap128 ptr v (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v h; low_lemma_store_mem128 b i v (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v t; () #push-options "--smtencoding.l_arith_repr boxwrap" let low_lemma_valid_mem128_64 b i h = reveal_opaque (`%S.valid_addr64) S.valid_addr64; reveal_opaque (`%S.valid_addr128) S.valid_addr128; low_lemma_valid_mem128 b i h; let ptr = buffer_addr b h + scale16 i in assert (buffer_addr b h + scale16 i + 8 = ptr + 8) #pop-options open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s let low_lemma_load_mem128_lo64 b i h = low_lemma_load_mem128 b i h; lo64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () let low_lemma_load_mem128_hi64 b i h = low_lemma_load_mem128 b i h; hi64_reveal (); S.get_heap_val128_reveal (); S.get_heap_val64_reveal (); S.get_heap_val32_reveal () //let same_domain_update128_64 b i v h = // low_lemma_valid_mem128_64 b i (_ih h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i) v (get_heap h); // Vale.Arch.MachineHeap.same_domain_update64 (buffer_addr b h + scale16 i + 8) v (get_heap h) open Vale.Def.Types_s let frame_get_heap32 (ptr:int) (mem1 mem2:S.machine_heap) : Lemma (requires (forall i. i >= ptr /\ i < ptr + 4 ==> mem1.[i] == mem2.[i])) (ensures S.get_heap_val32 ptr mem1 == S.get_heap_val32 ptr mem2) = S.get_heap_val32_reveal () let update_heap128_lo (ptr:int) (v:quad32) (mem:S.machine_heap) : Lemma (requires S.valid_addr128 ptr mem /\ v.hi2 == S.get_heap_val32 (ptr+8) mem /\ v.hi3 == S.get_heap_val32 (ptr+12) mem ) (ensures S.update_heap128 ptr v mem == S.update_heap32 (ptr+4) v.lo1 (S.update_heap32 ptr v.lo0 mem)) = reveal_opaque (`%S.valid_addr128) S.valid_addr128; S.update_heap128_reveal (); let mem0 = S.update_heap32 ptr v.lo0 mem in let mem1 = S.update_heap32 (ptr+4) v.lo1 mem0 in Vale.Arch.MachineHeap.frame_update_heap32 ptr v.lo0 mem; Vale.Arch.MachineHeap.frame_update_heap32 (ptr+4) v.lo1 mem0; Vale.Arch.MachineHeap.same_domain_update32 ptr v.lo0 mem; Vale.Arch.MachineHeap.same_domain_update32 (ptr+4) v.lo1 mem0; frame_get_heap32 (ptr+8) mem mem1; frame_get_heap32 (ptr+12) mem mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+8) mem1; Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+12) mem1 let low_lemma_load_mem128_lo_hi_full b i vfh t hid = reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_valid_mem128_64 b i vfh.vf_heap; () let low_lemma_store_mem128_lo64 b i v h = let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 0 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; S.get_heap_val128_reveal (); update_heap128_lo ptr v' (get_heap h); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal () let low_lemma_store_mem128_lo64_full b i v vfh t hid = let (h, mt, hk) = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let v' = insert_nat64 (buffer_read b i hk) v 0 in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v' (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v' hk in let mhk' = S.update_heap128 ptr v' (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v' h; low_lemma_store_mem128 b i v' (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v' h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v' hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v' t; low_lemma_store_mem128_lo64 b i v h; low_lemma_valid_mem128_64 b i h; assert (Map.equal mt (S.update_n (buffer_addr b h + scale16 i) 8 mt t)); () #push-options "--z3rlimit 20 --using_facts_from '* -LowStar.Monotonic.Buffer.loc_disjoint_includes_r'" #restart-solver let low_lemma_store_mem128_hi64 b i v h = reveal_opaque (`%S.valid_addr128) S.valid_addr128; let ptr = buffer_addr b h + scale16 i in let v128 = buffer_read b i h in let v' = insert_nat64 v128 v 1 in low_lemma_load_mem128 b i h; low_lemma_store_mem128 b i v' h; assert (S.valid_addr128 ptr (get_heap h)); Vale.Arch.MachineHeap.update_heap32_get_heap32 ptr (get_heap h); Vale.Arch.MachineHeap.update_heap32_get_heap32 (ptr+4) (get_heap h); S.get_heap_val128_reveal (); S.update_heap128_reveal (); S.update_heap64_reveal (); S.update_heap32_reveal (); insert_nat64_reveal () #pop-options
{ "checked_file": "/", "dependencies": [ "Vale.X64.Memory.fst.checked", "Vale.X64.Memory.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.BufferViewStore.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.Interop.Heap_s.fst.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.Memory_Sems.fst" }
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.BufferViewStore", "short_module": null }, { "abbrev": true, "full_module": "Vale.Interop.Base", "short_module": "IB" }, { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "Vale.Interop", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.Memory.buffer128 -> i: Prims.nat -> v: Vale.Def.Types_s.nat64 -> vfh: Vale.Arch.HeapImpl.vale_full_heap -> t: Vale.Arch.HeapTypes_s.taint -> hid: Vale.Arch.HeapImpl.heaplet_id -> FStar.Pervasives.Lemma (requires (let _ = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid, Mkvale_heap_layout?.vl_taint (Mkvale_full_heap?.vf_layout vfh) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ h mt = _ in i < FStar.Seq.Base.length (Vale.X64.Memory.buffer_as_seq h b) /\ Vale.X64.Memory.buffer_readable h b /\ Vale.X64.Memory.buffer_writeable b /\ Vale.X64.Memory.valid_layout_buffer b (Mkvale_full_heap?.vf_layout vfh) h true /\ Vale.X64.Memory.valid_taint_buf128 b h mt t /\ Vale.X64.Memory.mem_inv vfh) <: Type0)) (ensures (let h = Vale.Lib.Map16.get (Mkvale_full_heap?.vf_heaplets vfh) hid in let ptr = Vale.X64.Memory.buffer_addr b h + Vale.X64.Memory.scale16 i + 8 in let v' = Vale.Def.Types_s.insert_nat64 (Vale.X64.Memory.buffer_read b i h) v 1 in Vale.X64.Memory.buffer_addr b (Mkvale_full_heap?.vf_heap vfh) == Vale.X64.Memory.buffer_addr b h /\ Vale.Arch.MachineHeap_s.valid_addr64 ptr (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh)) /\ Vale.X64.Memory_Sems.is_full_update vfh (Vale.X64.Memory.buffer_write b i v' h) hid (Vale.Arch.MachineHeap_s.update_heap64 ptr v (Vale.Arch.Heap.heap_get (Vale.X64.Memory_Sems.coerce vfh))) (Vale.X64.Machine_Semantics_s.update_n ptr 8 (Vale.Arch.Heap.heap_taint (Vale.X64.Memory_Sems.coerce vfh)) t)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Memory.buffer128", "Prims.nat", "Vale.Def.Types_s.nat64", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.HeapImpl.heaplet_id", "Vale.Arch.HeapImpl.vale_heap", "FStar.Map.t", "Prims.int", "FStar.Set.equal", "FStar.Map.domain", "FStar.Set.complement", "FStar.Set.empty", "Prims.unit", "Prims._assert", "FStar.Map.equal", "Vale.X64.Machine_Semantics_s.update_n", "Prims.op_Addition", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.vuint128", "FStar.Mul.op_Star", "Vale.X64.Memory_Sems.low_lemma_valid_mem128_64", "Vale.X64.Memory_Sems.low_lemma_store_mem128_hi64", "Vale.X64.Memory_Sems.lemma_is_full_update", "Vale.Arch.HeapImpl.__proj__ValeHeap__item__mh", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Arch.MachineHeap.same_mem_get_heap_val128", "Vale.X64.Memory_Sems.in_bounds128", "Vale.Arch.MachineHeap.frame_update_heap128", "Vale.X64.Memory_Sems.low_lemma_store_mem128", "Vale.Lib.Map16.get", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "FStar.Pervasives.reveal_opaque", "Vale.Arch.HeapTypes_s.base_typ", "Vale.X64.Memory.buffer", "Vale.Arch.HeapImpl.vale_heap_layout", "FStar.Pervasives.Native.option", "Prims.bool", "Vale.Def.Prop_s.prop0", "Vale.X64.Memory.valid_layout_buffer_id", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.update_heap128", "Vale.X64.Memory_Sems.get_heap", "Vale.X64.Memory.buffer_write", "Vale.Arch.HeapTypes_s.memTaint_t", "Prims.l_Forall", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "FStar.Map.sel", "Prims.l_or", "Vale.Arch.Heap.heap_taint", "Vale.X64.Memory_Sems.coerce", "Vale.Arch.Heap.heap_impl", "Vale.Arch.Heap.heap_get", "Vale.X64.Memory.scale16", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.insert_nat64", "Vale.X64.Memory.buffer_read", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout" ]
[]
false
false
true
false
false
let low_lemma_store_mem128_hi64_full b i v vfh t hid =
reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; let h, mt, hk = (vfh.vf_heap, vfh.vf_layout.vl_taint, Map16.get vfh.vf_heaplets hid) in let v' = insert_nat64 (buffer_read b i h) v 1 in let ptr = buffer_addr b hk + scale16 i in let mh' = S.update_heap128 ptr v' (heap_get (coerce vfh)) in let mt' = S.update_n ptr 16 (heap_taint (coerce vfh)) t in let hk' = buffer_write b i v' hk in let mhk' = S.update_heap128 ptr v' (get_heap hk) in reveal_opaque (`%valid_layout_buffer_id) valid_layout_buffer_id; low_lemma_store_mem128 b i v' h; low_lemma_store_mem128 b i v' (Map16.get vfh.vf_heaplets hid); Vale.Arch.MachineHeap.frame_update_heap128 ptr v' h.mh; Vale.Arch.MachineHeap.frame_update_heap128 ptr v' hk.mh; in_bounds128 hk b i; Vale.Arch.MachineHeap.same_mem_get_heap_val128 ptr mh' mhk'; lemma_is_full_update vfh h hk hk' hid h.mh mh' hk.mh mhk' mt mt' TUInt128 b ptr 16 i v' t; low_lemma_store_mem128_hi64 b i v h; low_lemma_valid_mem128_64 b i h; assert (Map.equal mt (S.update_n (buffer_addr b h + 16 * i + 8) 8 mt t)); ()
false
Hacl.Spec.K256.PrecompTable.fst
Hacl.Spec.K256.PrecompTable.felem_to_list_lemma_eval
val felem_to_list_lemma_eval: x:S.felem -> Lemma (as_nat5 (list_as_felem5 (felem_to_list x)) == x)
val felem_to_list_lemma_eval: x:S.felem -> Lemma (as_nat5 (list_as_felem5 (felem_to_list x)) == x)
let felem_to_list_lemma_eval x = felem_to_list_index_lemma x; let x0 = x % pow52 in let x1 = x / pow52 % pow52 in let x2 = x / pow104 % pow52 in let x3 = x / pow156 % pow52 in let x4 = x / pow208 in let (f0, f1, f2, f3, f4) = list_as_felem5 (felem_to_list x) in let nat_x = as_nat5 (f0, f1, f2, f3, f4) in assert (nat_x == x0 + x1 * pow52 + x2 * pow104 + x3 * pow156 + x4 * pow208); calc (==) { x0 + x1 * pow52 + x2 * pow104 + x3 * pow156 + x4 * pow208; (==) { } x0 + x1 * pow52 + x2 * pow104 + (x / pow156 % pow52) * pow156 + x / pow208 * pow208; (==) { lemma_mod_pow2_sub x 156 52 } x0 + x1 * pow52 + x2 * pow104 + x % pow208 - x % pow156 + x / pow208 * pow208; (==) { Math.Lemmas.euclidean_division_definition x pow208 } x0 + x1 * pow52 + (x / pow104 % pow52) * pow104 - x % pow156 + x; (==) { lemma_mod_pow2_sub x 104 52 } x0 + (x / pow52 % pow52) * pow52 - x % pow104 + x; (==) { lemma_mod_pow2_sub x 52 52 } x; }
{ "file_name": "code/k256/Hacl.Spec.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 116, "start_col": 0, "start_line": 94 }
module Hacl.Spec.K256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.K256.Field52.Definitions open Hacl.Impl.K256.Point module S = Spec.K256 module FL = FStar.List.Tot module SPT = Hacl.Spec.PrecompBaseTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let create5_lseq (x0 x1 x2 x3 x4:uint64) : lseq uint64 5 = let l = [x0; x1; x2; x3; x4] in assert_norm (FL.length l = 5); Seq.seq_of_list l val create5_lemma (x0 x1 x2 x3 x4:uint64) : Lemma (let s = create5_lseq x0 x1 x2 x3 x4 in s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3 /\ s.[4] == x4) let create5_lemma x0 x1 x2 x3 x4 = Seq.elim_of_list [x0; x1; x2; x3; x4] //----------------------------------- noextract let list_as_felem5 (f:felem_list) : felem5 = let x = Seq.seq_of_list f <: lseq uint64 5 in as_felem5_lseq x val felem_to_list_index_lemma: x:S.felem -> Lemma (let (f0, f1, f2, f3, f4) = list_as_felem5 (felem_to_list x) in let x0 = x % pow52 in let x1 = x / pow52 % pow52 in let x2 = x / pow104 % pow52 in let x3 = x / pow156 % pow52 in let x4 = x / pow208 in v f0 == x0 /\ v f1 == x1 /\ v f2 == x2 /\ v f3 == x3 /\ v f4 == x4) let felem_to_list_index_lemma x = let x0 = x % pow52 in let x1 = x / pow52 % pow52 in let x2 = x / pow104 % pow52 in let x3 = x / pow156 % pow52 in let x4 = x / pow208 in let f = felem_to_list x in let (f0, f1, f2, f3, f4) = list_as_felem5 f in create5_lemma (u64 x0) (u64 x1) (u64 x2) (u64 x3) (u64 x4); assert (v f0 == x0 /\ v f1 == x1 /\ v f2 == x2 /\ v f3 == x3 /\ v f4 == x4) val felem_to_list_lemma_fits: x:S.felem -> Lemma (felem_fits5 (list_as_felem5 (felem_to_list x)) (1, 1, 1, 1, 1)) let felem_to_list_lemma_fits x = felem_to_list_index_lemma x; let x0 = x % pow52 in let x1 = x / pow52 % pow52 in let x2 = x / pow104 % pow52 in let x3 = x / pow156 % pow52 in let x4 = x / pow208 in assert (felem_fits1 (u64 x0) 1); assert (felem_fits1 (u64 x1) 1); assert (felem_fits1 (u64 x2) 1); assert (felem_fits1 (u64 x3) 1); Math.Lemmas.lemma_div_lt_nat x 256 208; assert (felem_fits_last1 (u64 x4) 1) val lemma_mod_pow2_sub: x:nat -> a:nat -> b:nat -> Lemma (x / pow2 a % pow2 b * pow2 a == x % pow2 (a + b) - x % pow2 a) let lemma_mod_pow2_sub x a b = calc (==) { x / pow2 a % pow2 b * pow2 a; (==) { Math.Lemmas.pow2_modulo_division_lemma_1 x a (a + b) } x % pow2 (a + b) / pow2 a * pow2 a; (==) { Math.Lemmas.euclidean_division_definition (x % pow2 (a + b)) (pow2 a) } x % pow2 (a + b) - x % pow2 (a + b) % pow2 a; (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 x a (a + b) } x % pow2 (a + b) - x % pow2 a; } val felem_to_list_lemma_eval: x:S.felem -> Lemma (as_nat5 (list_as_felem5 (felem_to_list x)) == x)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.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": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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
x: Spec.K256.PointOps.felem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Field52.Definitions.as_nat5 (Hacl.Spec.K256.PrecompTable.list_as_felem5 (Hacl.Spec.K256.PrecompTable.felem_to_list x)) == x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.felem", "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Hacl.Spec.K256.Field52.Definitions.pow52", "Hacl.Spec.K256.Field52.Definitions.pow104", "Hacl.Spec.K256.Field52.Definitions.pow156", "Hacl.Spec.K256.Field52.Definitions.pow208", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Subtraction", "Prims.op_Modulus", "Prims.op_Division", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.K256.PrecompTable.lemma_mod_pow2_sub", "FStar.Math.Lemmas.euclidean_division_definition", "Prims._assert", "Prims.nat", "Hacl.Spec.K256.Field52.Definitions.as_nat5", "FStar.Pervasives.Native.Mktuple5", "Hacl.Spec.K256.Field52.Definitions.felem5", "Hacl.Spec.K256.PrecompTable.list_as_felem5", "Hacl.Spec.K256.PrecompTable.felem_to_list", "Hacl.Spec.K256.PrecompTable.felem_to_list_index_lemma" ]
[]
false
false
true
false
false
let felem_to_list_lemma_eval x =
felem_to_list_index_lemma x; let x0 = x % pow52 in let x1 = x / pow52 % pow52 in let x2 = x / pow104 % pow52 in let x3 = x / pow156 % pow52 in let x4 = x / pow208 in let f0, f1, f2, f3, f4 = list_as_felem5 (felem_to_list x) in let nat_x = as_nat5 (f0, f1, f2, f3, f4) in assert (nat_x == x0 + x1 * pow52 + x2 * pow104 + x3 * pow156 + x4 * pow208); calc ( == ) { x0 + x1 * pow52 + x2 * pow104 + x3 * pow156 + x4 * pow208; ( == ) { () } x0 + x1 * pow52 + x2 * pow104 + (x / pow156 % pow52) * pow156 + (x / pow208) * pow208; ( == ) { lemma_mod_pow2_sub x 156 52 } x0 + x1 * pow52 + x2 * pow104 + x % pow208 - x % pow156 + (x / pow208) * pow208; ( == ) { Math.Lemmas.euclidean_division_definition x pow208 } x0 + x1 * pow52 + (x / pow104 % pow52) * pow104 - x % pow156 + x; ( == ) { lemma_mod_pow2_sub x 104 52 } x0 + (x / pow52 % pow52) * pow52 - x % pow104 + x; ( == ) { lemma_mod_pow2_sub x 52 52 } x; }
false
Hacl.Spec.Poly1305.Field32xN.Lemmas.fst
Hacl.Spec.Poly1305.Field32xN.Lemmas.lemma_fmul_r4_normalize51_expand
val lemma_fmul_r4_normalize51_expand: v2:felem5 4 -> out:felem5 4 -> Lemma (requires (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (uint64xN_v v20).[0] == (uint64xN_v o0).[0] + (uint64xN_v o0).[1] + (uint64xN_v o0).[2] + (uint64xN_v o0).[3] /\ (uint64xN_v v21).[0] == (uint64xN_v o1).[0] + (uint64xN_v o1).[1] + (uint64xN_v o1).[2] + (uint64xN_v o1).[3] /\ (uint64xN_v v22).[0] == (uint64xN_v o2).[0] + (uint64xN_v o2).[1] + (uint64xN_v o2).[2] + (uint64xN_v o2).[3] /\ (uint64xN_v v23).[0] == (uint64xN_v o3).[0] + (uint64xN_v o3).[1] + (uint64xN_v o3).[2] + (uint64xN_v o3).[3] /\ (uint64xN_v v24).[0] == (uint64xN_v o4).[0] + (uint64xN_v o4).[1] + (uint64xN_v o4).[2] + (uint64xN_v o4).[3])) (ensures (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (feval5 v2).[0] == Vec.pfadd (Vec.pfadd (Vec.pfadd (feval5 out).[0] (feval5 out).[1]) (feval5 out).[2]) (feval5 out).[3]))
val lemma_fmul_r4_normalize51_expand: v2:felem5 4 -> out:felem5 4 -> Lemma (requires (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (uint64xN_v v20).[0] == (uint64xN_v o0).[0] + (uint64xN_v o0).[1] + (uint64xN_v o0).[2] + (uint64xN_v o0).[3] /\ (uint64xN_v v21).[0] == (uint64xN_v o1).[0] + (uint64xN_v o1).[1] + (uint64xN_v o1).[2] + (uint64xN_v o1).[3] /\ (uint64xN_v v22).[0] == (uint64xN_v o2).[0] + (uint64xN_v o2).[1] + (uint64xN_v o2).[2] + (uint64xN_v o2).[3] /\ (uint64xN_v v23).[0] == (uint64xN_v o3).[0] + (uint64xN_v o3).[1] + (uint64xN_v o3).[2] + (uint64xN_v o3).[3] /\ (uint64xN_v v24).[0] == (uint64xN_v o4).[0] + (uint64xN_v o4).[1] + (uint64xN_v o4).[2] + (uint64xN_v o4).[3])) (ensures (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (feval5 v2).[0] == Vec.pfadd (Vec.pfadd (Vec.pfadd (feval5 out).[0] (feval5 out).[1]) (feval5 out).[2]) (feval5 out).[3]))
let lemma_fmul_r4_normalize51_expand v2 out = let (v20, v21, v22, v23, v24) = as_tup64_i v2 0 in let (o0, o1, o2, o3, o4) = out in calc (==) { as_nat5 (v20, v21, v22, v23, v24) % Vec.prime; (==) { } (as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1) + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1)) (as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) Vec.prime } ((as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1)) % Vec.prime + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.modulo_distributivity (as_nat5 (as_tup64_i out 0)) (as_nat5 (as_tup64_i out 1)) Vec.prime } (((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + as_nat5 (as_tup64_i out 2)) (as_nat5 (as_tup64_i out 3)) Vec.prime } ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + as_nat5 (as_tup64_i out 2)) % Vec.prime + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (((feval5 out).[0] + (feval5 out).[1]) % Vec.prime) (as_nat5 (as_tup64_i out 2)) Vec.prime } ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime) (as_nat5 (as_tup64_i out 3)) Vec.prime } ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime + (feval5 out).[3]) % Vec.prime; }; assert ((feval5 v2).[0] == ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime + (feval5 out).[3]) % Vec.prime)
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Field32xN.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 120, "end_line": 548, "start_col": 0, "start_line": 525 }
module Hacl.Spec.Poly1305.Field32xN.Lemmas open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open Hacl.Spec.Poly1305.Field32xN open Hacl.Poly1305.Field32xN.Lemmas0 open Hacl.Poly1305.Field32xN.Lemmas1 open Hacl.Poly1305.Field32xN.Lemmas2 module Vec = Hacl.Spec.Poly1305.Vec #set-options "--z3rlimit 100 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1 --using_facts_from '* -FStar.Seq'" val lemma_feval_is_fas_nat_i: #w:lanes -> f:felem5 w{felem_less5 f (pow2 128)} -> i:size_nat{i < w} -> Lemma ((feval5 f).[i] == (fas_nat5 f).[i]) let lemma_feval_is_fas_nat_i #w f i = assert_norm (pow2 128 < Vec.prime); assert ((feval5 f).[i] == (as_nat5 (transpose f).[i]) % Vec.prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 (transpose f).[i]) Vec.prime val lemma_feval_is_fas_nat: #w:lanes -> f:felem5 w{felem_less5 f (pow2 128)} -> Lemma (forall (i:nat). i < w ==> (fas_nat5 f).[i] == (feval5 f).[i]) let lemma_feval_is_fas_nat #w f = FStar.Classical.forall_intro (lemma_feval_is_fas_nat_i #w f) val precomp_r5_fits_lemma: #w:lanes -> r:felem5 w{felem_fits5 r (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (precomp_r5 #w r) (5, 5, 5, 5, 5)) [SMTPat (precomp_r5 #w r)] let precomp_r5_fits_lemma #w r = FStar.Classical.forall_intro (precomp_r5_as_tup64 #w r) val precomp_r5_fits_lemma2: #w:lanes -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> Lemma (felem_fits5 (precomp_r5 #w r) (10, 10, 10, 10, 10)) [SMTPat (precomp_r5 #w r)] let precomp_r5_fits_lemma2 #w r = FStar.Classical.forall_intro (precomp_r5_as_tup64 #w r) val precomp_r5_zeros: w:lanes -> Lemma (let r = (zero w, zero w, zero w, zero w, zero w) in precomp_r5 r == (zero w, zero w, zero w, zero w, zero w)) let precomp_r5_zeros w = let r = (zero w, zero w, zero w, zero w, zero w) in let (r0, r1, r2, r3, r4) = precomp_r5 r in let aux (i:nat{i < w}) : Lemma ((vec_v (vec_smul_mod (zero w) (u64 5))).[i] == u64 0) = () in Classical.forall_intro aux; eq_intro (vec_v (vec_smul_mod (zero w) (u64 5))) (vec_v (zero w)); vecv_extensionality (vec_smul_mod (zero w) (u64 5)) (zero w) val fadd5_fits_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)} -> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)} -> Lemma (felem_fits5 (fadd5 f1 f2) (3,3,3,3,3)) [SMTPat (fadd5 f1 f2)] let fadd5_fits_lemma #w f1 f2 = let (f10, f11, f12, f13, f14) = f1 in let (f20, f21, f22, f23, f24) = f2 in let o = fadd5 f1 f2 in vec_add_mod_lemma f10 f20; vec_add_mod_lemma f11 f21; vec_add_mod_lemma f12 f22; vec_add_mod_lemma f13 f23; vec_add_mod_lemma f14 f24 val fadd5_eval_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)} -> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)} -> Lemma (feval5 (fadd5 f1 f2) == map2 Vec.pfadd (feval5 f1) (feval5 f2)) [SMTPat (fadd5 f1 f2)] let fadd5_eval_lemma #w f1 f2 = let o = fadd5 f1 f2 in FStar.Classical.forall_intro (fadd5_eval_lemma_i f1 f2); eq_intro (feval5 o) (map2 Vec.pfadd (feval5 f1) (feval5 f2)) val mul_felem5_fits_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10)} -> Lemma (felem_wide_fits5 (mul_felem5 #w f1 r r5) (126, 102, 78, 54, 30)) [SMTPat (mul_felem5 #w f1 r r5)] let mul_felem5_fits_lemma #w f1 r r5 = let (r0, r1, r2, r3, r4) = r in let (f10, f11, f12, f13, f14) = f1 in let (r50, r51, r52, r53, r54) = r5 in let (a0,a1,a2,a3,a4) = smul_felem5 #w f10 (r0,r1,r2,r3,r4) in smul_felem5_fits_lemma #w #3 #(2,2,2,2,2) f10 (r0,r1,r2,r3,r4); let (a10,a11,a12,a13,a14) = smul_add_felem5 #w f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4) in smul_add_felem5_fits_lemma #w #3 #(10,2,2,2,2) #(6,6,6,6,6) f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4); let (a20,a21,a22,a23,a24) = smul_add_felem5 #w f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14) in smul_add_felem5_fits_lemma #w #3 #(10,10,2,2,2) #(36,12,12,12,12) f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14); let (a30,a31,a32,a33,a34) = smul_add_felem5 #w f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24) in smul_add_felem5_fits_lemma #w #3 #(10,10,10,2,2) #(66,42,18,18,18) f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24); let (a40,a41,a42,a43,a44) = smul_add_felem5 #w f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34) in smul_add_felem5_fits_lemma #w #3 #(10,10,10,10,2) #(96,72,48,24,24) f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34) val mul_felem5_eval_lemma_i: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10) /\ r5 == precomp_r5 r} -> i:nat{i < w} -> Lemma ((feval5 (mul_felem5 #w f1 r r5)).[i] == (feval5 f1).[i] `Vec.pfmul` (feval5 r).[i]) let mul_felem5_eval_lemma_i #w f1 r r5 i = let (r0, r1, r2, r3, r4) = r in let (f10, f11, f12, f13, f14) = f1 in let (r50, r51, r52, r53, r54) = r5 in let (a0,a1,a2,a3,a4) = smul_felem5 #w f10 (r0,r1,r2,r3,r4) in smul_felem5_eval_lemma #w #3 #(2,2,2,2,2) f10 (r0,r1,r2,r3,r4); smul_felem5_fits_lemma #w #3 #(2,2,2,2,2) f10 (r0,r1,r2,r3,r4); assert ((fas_nat5 (a0,a1,a2,a3,a4)).[i] == (uint64xN_v f10).[i] * (fas_nat5 (r0,r1,r2,r3,r4)).[i]); let (a10,a11,a12,a13,a14) = smul_add_felem5 #w f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4) in smul_add_felem5_eval_lemma #w #3 #(10,2,2,2,2) #(6,6,6,6,6) f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4); smul_add_felem5_fits_lemma #w #3 #(10,2,2,2,2) #(6,6,6,6,6) f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4); assert ((fas_nat5 (a10,a11,a12,a13,a14)).[i] == (fas_nat5 (a0,a1,a2,a3,a4)).[i] + (uint64xN_v f11).[i] * (fas_nat5 (r54,r0,r1,r2,r3)).[i]); let (a20,a21,a22,a23,a24) = smul_add_felem5 #w f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14) in smul_add_felem5_eval_lemma #w #3 #(10,10,2,2,2) #(36,12,12,12,12) f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14); smul_add_felem5_fits_lemma #w #3 #(10,10,2,2,2) #(36,12,12,12,12) f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14); assert ((fas_nat5 (a20,a21,a22,a23,a24)).[i] == (fas_nat5 (a10,a11,a12,a13,a14)).[i] + (uint64xN_v f12).[i] * (fas_nat5 (r53,r54,r0,r1,r2)).[i]); let (a30,a31,a32,a33,a34) = smul_add_felem5 #w f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24) in smul_add_felem5_eval_lemma #w #3 #(10,10,10,2,2) #(66,42,18,18,18) f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24); smul_add_felem5_fits_lemma #w #3 #(10,10,10,2,2) #(66,42,18,18,18) f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24); assert ((fas_nat5 (a30,a31,a32,a33,a34)).[i] == (fas_nat5 (a20,a21,a22,a23,a24)).[i] + (uint64xN_v f13).[i] * (fas_nat5 (r52,r53,r54,r0,r1)).[i]); let (a40,a41,a42,a43,a44) = smul_add_felem5 #w f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34) in smul_add_felem5_eval_lemma #w #3 #(10,10,10,10,2) #(96,72,48,24,24) f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34); smul_add_felem5_fits_lemma #w #3 #(10,10,10,10,2) #(96,72,48,24,24) f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34); assert ((fas_nat5 (a40,a41,a42,a43,a44)).[i] == (fas_nat5 (a30,a31,a32,a33,a34)).[i] + (uint64xN_v f14).[i] * (fas_nat5 (r51,r52,r53,r54,r0)).[i]); assert ((fas_nat5 (a40,a41,a42,a43,a44)).[i] == (uint64xN_v f10).[i] * (fas_nat5 (r0,r1,r2,r3,r4)).[i] + (uint64xN_v f11).[i] * (fas_nat5 (r54,r0,r1,r2,r3)).[i] + (uint64xN_v f12).[i] * (fas_nat5 (r53,r54,r0,r1,r2)).[i] + (uint64xN_v f13).[i] * (fas_nat5 (r52,r53,r54,r0,r1)).[i] + (uint64xN_v f14).[i] * (fas_nat5 (r51,r52,r53,r54,r0)).[i]); mul_felem5_eval_as_tup64 #w f1 r r5 i; mul_felem5_lemma (as_tup64_i f1 i) (as_tup64_i r i) val mul_felem5_eval_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10) /\ r5 == precomp_r5 r} -> Lemma (feval5 (mul_felem5 #w f1 r r5) == map2 (Vec.pfmul) (feval5 f1) (feval5 r)) [SMTPat (mul_felem5 #w f1 r r5)] let mul_felem5_eval_lemma #w f1 r r5 = let tmp = map2 (Vec.pfmul) (feval5 f1) (feval5 r) in FStar.Classical.forall_intro (mul_felem5_eval_lemma_i #w f1 r r5); eq_intro (feval5 (mul_felem5 #w f1 r r5)) tmp val fmul_r5_fits_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10)} -> Lemma (felem_fits5 (fmul_r5 #w f1 r r5) (1, 2, 1, 1, 2)) [SMTPat (fmul_r5 #w f1 r r5)] let fmul_r5_fits_lemma #w f1 r r5 = let tmp = mul_felem5 f1 r r5 in mul_felem5_fits_lemma #w f1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_fits_lemma #w tmp val fmul_r5_eval_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10) /\ r5 == precomp_r5 r} -> Lemma (feval5 (fmul_r5 #w f1 r r5) == map2 (Vec.pfmul) (feval5 f1) (feval5 r)) [SMTPat (fmul_r5 #w f1 r r5)] let fmul_r5_eval_lemma #w f1 r r5 = let tmp = mul_felem5 f1 r r5 in mul_felem5_eval_lemma #w f1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_eval_lemma #w tmp val fadd_mul_r5_fits_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (2, 2, 2, 2, 2)} -> f1:felem5 w{felem_fits5 f1 (1, 1, 1, 1, 1)} -> r:felem5 w{felem_fits5 r (1, 1, 1, 1, 1)} -> r5:felem5 w{felem_fits5 r5 (5, 5, 5, 5, 5)} -> Lemma (felem_fits5 (fadd_mul_r5 acc f1 r r5) (1, 2, 1, 1, 2)) [SMTPat (fadd_mul_r5 acc f1 r r5)] let fadd_mul_r5_fits_lemma #w acc f1 r r5 = let acc1 = fadd5 acc f1 in fadd5_fits_lemma #w acc f1; let tmp = mul_felem5 acc1 r r5 in mul_felem5_fits_lemma #w acc1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_fits_lemma #w tmp val fadd_mul_r5_eval_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (2, 2, 2, 2, 2)} -> f1:felem5 w{felem_fits5 f1 (1, 1, 1, 1, 1)} -> r:felem5 w{felem_fits5 r (1, 1, 1, 1, 1)} -> r5:felem5 w{felem_fits5 r5 (5, 5, 5, 5, 5) /\ r5 == precomp_r5 r} -> Lemma (feval5 (fadd_mul_r5 acc f1 r r5) == map2 (Vec.pfmul) (map2 (Vec.pfadd) (feval5 acc) (feval5 f1)) (feval5 r)) [SMTPat (fadd_mul_r5 acc f1 r r5)] let fadd_mul_r5_eval_lemma #w acc f1 r r5 = let acc1 = fadd5 acc f1 in fadd5_eval_lemma #w acc f1; let tmp = mul_felem5 acc1 r r5 in mul_felem5_eval_lemma #w acc1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_eval_lemma #w tmp val reduce_felem5_eval_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (2, 2, 2, 2, 2)} -> Lemma (felem_fits5 (reduce_felem5 f) (1, 1, 1, 1, 1) /\ (feval5 f).[0] == (fas_nat5 (reduce_felem5 f)).[0]) [SMTPat (reduce_felem5 f)] let reduce_felem5_eval_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f; let f = carry_full_felem5 f in carry_reduce_felem5_lemma #w f; subtract_p5_felem5_lemma #w (carry_full_felem5 f) val fmul_r2_normalize50: acc:felem5 2 -> r:felem5 2 -> r2:felem5 2 -> Pure (felem5 2) (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r2 (2, 2, 2, 2, 2) /\ feval5 r2 == Vec.compute_r2 (feval5 r).[0]) (ensures fun a -> let fr21 = create2 (feval5 r2).[0] (feval5 r).[0] in feval5 a == Vec.fmul (feval5 acc) fr21 /\ felem_fits5 a (1, 2, 1, 1, 2)) let fmul_r2_normalize50 (a0, a1, a2, a3, a4) (r0, r1, r2, r3, r4) (r20, r21, r22, r23, r24) = let r210 = vec_interleave_low r20 r0 in vec_interleave_low_lemma2 r20 r0; let r211 = vec_interleave_low r21 r1 in vec_interleave_low_lemma2 r21 r1; let r212 = vec_interleave_low r22 r2 in vec_interleave_low_lemma2 r22 r2; let r213 = vec_interleave_low r23 r3 in vec_interleave_low_lemma2 r23 r3; let r214 = vec_interleave_low r24 r4 in vec_interleave_low_lemma2 r24 r4; let acc = (a0, a1, a2, a3, a4) in let fr = (r0, r1, r2, r3, r4) in let fr2 = (r20, r21, r22, r23, r24) in assert ((feval5 fr2).[0] == Vec.pfmul ((feval5 fr).[0]) ((feval5 fr).[0])); let fr21 = (r210, r211, r212, r213, r214) in eq_intro (feval5 fr21) (create2 (feval5 fr2).[0] (feval5 fr).[0]); assert (feval5 fr21 == create2 (feval5 fr2).[0] (feval5 fr).[0]); assert (felem_fits5 fr21 (2, 2, 2, 2, 2)); let fr215 = precomp_r5 #2 fr21 in let a = fmul_r5 #2 acc fr21 fr215 in fmul_r5_eval_lemma acc fr21 fr215; fmul_r5_fits_lemma acc fr21 fr215; assert (feval5 a == Vec.fmul (feval5 acc) (feval5 fr21)); assert (felem_fits5 a (1, 2, 1, 1, 2)); a #push-options "--z3rlimit 150" val fmul_r2_normalize51: a:felem5 2 -> fa1:felem5 2 -> Pure (felem5 2) (requires felem_fits5 a (1, 2, 1, 1, 2) /\ felem_fits5 fa1 (1, 2, 1, 1, 2) /\ feval5 fa1 == create2 (feval5 a).[1] (feval5 a).[1]) (ensures fun out -> (feval5 out).[0] == Vec.pfadd (feval5 a).[0] (feval5 a).[1] /\ felem_fits5 out (2, 4, 2, 2, 4)) let fmul_r2_normalize51 a fa1 = let (a0, a1, a2, a3, a4) = a in let (a10, a11, a12, a13, a14) = fa1 in let o0 = vec_add_mod a0 a10 in let o1 = vec_add_mod a1 a11 in let o2 = vec_add_mod a2 a12 in let o3 = vec_add_mod a3 a13 in let o4 = vec_add_mod a4 a14 in let out = (o0, o1, o2, o3, o4) in let (a0, a1, a2, a3, a4) = as_tup64_i a 0 in let (a10, a11, a12, a13, a14) = as_tup64_i fa1 0 in let (o0, o1, o2, o3, o4) = as_tup64_i out 0 in FStar.Math.Lemmas.modulo_lemma (v a0 + v a10) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a1 + v a11) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a2 + v a12) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a3 + v a13) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a4 + v a14) (pow2 64); assert (felem_fits5 out (2, 4, 2, 2, 4)); calc (==) { ((feval5 a).[0] + (feval5 a).[1]) % Vec.prime; (==) { } (as_nat5 (a0, a1, a2, a3, a4) % Vec.prime + as_nat5 (a10, a11, a12, a13, a14) % Vec.prime) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat5 (a0, a1, a2, a3, a4)) (as_nat5 (a10, a11, a12, a13, a14)) Vec.prime; FStar.Math.Lemmas.lemma_mod_plus_distr_r (as_nat5 (a0, a1, a2, a3, a4) % Vec.prime) (as_nat5 (a10, a11, a12, a13, a14)) Vec.prime } (as_nat5 (a0, a1, a2, a3, a4) + as_nat5 (a10, a11, a12, a13, a14)) % Vec.prime; (==) { } (feval5 out).[0]; }; out #pop-options val fmul_r2_normalize5_lemma: acc:felem5 2 -> r:felem5 2 -> r2:felem5 2 -> Lemma (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r2 (2, 2, 2, 2, 2) /\ feval5 r2 == Vec.compute_r2 (feval5 r).[0]) (ensures (let out = fmul_r2_normalize5 acc r r2 in felem_fits5 out (2, 1, 1, 1, 1) /\ (feval5 out).[0] == Vec.normalize_2 (feval5 r).[0] (feval5 acc))) [SMTPat (fmul_r2_normalize5 acc r r2)] let fmul_r2_normalize5_lemma acc r r2 = let a = fmul_r2_normalize50 acc r r2 in let (a0, a1, a2, a3, a4) = a in let a10 = vec_interleave_high a0 a0 in vec_interleave_high_lemma2 a0 a0; let a11 = vec_interleave_high a1 a1 in vec_interleave_high_lemma2 a1 a1; let a12 = vec_interleave_high a2 a2 in vec_interleave_high_lemma2 a2 a2; let a13 = vec_interleave_high a3 a3 in vec_interleave_high_lemma2 a3 a3; let a14 = vec_interleave_high a4 a4 in vec_interleave_high_lemma2 a4 a4; let fa1 = (a10, a11, a12, a13, a14) in eq_intro (feval5 fa1) (create2 (feval5 a).[1] (feval5 a).[1]); assert (feval5 fa1 == create2 (feval5 a).[1] (feval5 a).[1]); assert (felem_fits5 fa1 (1, 2, 1, 1, 2)); let out = fmul_r2_normalize51 a fa1 in assert ((feval5 out).[0] == Vec.pfadd (feval5 a).[0] (feval5 a).[1]); let res = carry_full_felem5 out in carry_full_felem5_lemma out val fmul_r4_normalize50: acc:felem5 4 -> r:felem5 4 -> r2:felem5 4 -> r3:felem5 4 -> r4:felem5 4 -> Pure (felem5 4) (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r2 (2, 2, 2, 2, 2) /\ felem_fits5 r3 (2, 2, 2, 2, 2) /\ felem_fits5 r4 (2, 2, 2, 2, 2) /\ feval5 r2 == Vec.fmul (feval5 r) (feval5 r) /\ feval5 r3 == Vec.fmul (feval5 r2) (feval5 r) /\ feval5 r4 == Vec.compute_r4 (feval5 r).[0]) (ensures fun out -> let fr4321 = create4 (feval5 r4).[0] (feval5 r3).[0] (feval5 r2).[0] (feval5 r).[0] in feval5 out == Vec.fmul (feval5 acc) fr4321 /\ felem_fits5 out (1, 2, 1, 1, 2)) let fmul_r4_normalize50 acc fr fr2 fr3 fr4 = let (r10, r11, r12, r13, r14) = fr in let (r20, r21, r22, r23, r24) = fr2 in let (r30, r31, r32, r33, r34) = fr3 in let (r40, r41, r42, r43, r44) = fr4 in let (a0, a1, a2, a3, a4) = acc in let v12120 = vec_interleave_low r20 r10 in vec_interleave_low_lemma_uint64_4 r20 r10; let v34340 = vec_interleave_low r40 r30 in vec_interleave_low_lemma_uint64_4 r40 r30; let r12340 = vec_interleave_low_n 2 v34340 v12120 in vec_interleave_low_n_lemma_uint64_4_2 v34340 v12120; let v12121 = vec_interleave_low r21 r11 in vec_interleave_low_lemma_uint64_4 r21 r11; let v34341 = vec_interleave_low r41 r31 in vec_interleave_low_lemma_uint64_4 r41 r31; let r12341 = vec_interleave_low_n 2 v34341 v12121 in vec_interleave_low_n_lemma_uint64_4_2 v34341 v12121; let v12122 = vec_interleave_low r22 r12 in vec_interleave_low_lemma_uint64_4 r22 r12; let v34342 = vec_interleave_low r42 r32 in vec_interleave_low_lemma_uint64_4 r42 r32; let r12342 = vec_interleave_low_n 2 v34342 v12122 in vec_interleave_low_n_lemma_uint64_4_2 v34342 v12122; let v12123 = vec_interleave_low r23 r13 in vec_interleave_low_lemma_uint64_4 r23 r13; let v34343 = vec_interleave_low r43 r33 in vec_interleave_low_lemma_uint64_4 r43 r33; let r12343 = vec_interleave_low_n 2 v34343 v12123 in vec_interleave_low_n_lemma_uint64_4_2 v34343 v12123; let v12124 = vec_interleave_low r24 r14 in vec_interleave_low_lemma_uint64_4 r24 r14; let v34344 = vec_interleave_low r44 r34 in vec_interleave_low_lemma_uint64_4 r44 r34; let r12344 = vec_interleave_low_n 2 v34344 v12124 in vec_interleave_low_n_lemma_uint64_4_2 v34344 v12124; let fr1234 = (r12340, r12341, r12342, r12343, r12344) in eq_intro (feval5 fr1234) (create4 (feval5 fr4).[0] (feval5 fr3).[0] (feval5 fr2).[0] (feval5 fr).[0]); let fr12345 = precomp_r5 #4 fr1234 in let out = fmul_r5 #4 acc fr1234 fr12345 in fmul_r5_eval_lemma acc fr1234 fr12345; fmul_r5_fits_lemma acc fr1234 fr12345; out val lemma_fmul_r4_normalize51: #m:scale32{m <= 2} -> o:uint64xN 4{felem_fits1 o m} -> Lemma (let v00 = vec_interleave_high_n 2 o o in let v10 = vec_add_mod o v00 in let v10h = vec_interleave_high v10 v10 in let v20 = vec_add_mod v10 v10h in felem_fits1 v20 (4 * m) /\ (uint64xN_v v20).[0] == (uint64xN_v o).[0] + (uint64xN_v o).[1] + (uint64xN_v o).[2] + (uint64xN_v o).[3]) let lemma_fmul_r4_normalize51 #m o = let v00 = vec_interleave_high_n 2 o o in vec_interleave_high_n_lemma_uint64_4_2 o o; let (o0, o1, o2, o3) = ((vec_v o).[0], (vec_v o).[1], (vec_v o).[2], (vec_v o).[3]) in assert (vec_v v00 == create4 o2 o3 o2 o3); let v10 = vec_add_mod o v00 in FStar.Math.Lemmas.modulo_lemma (v o0 + v o2) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v o1 + v o3) (pow2 64); assert (v (vec_v v10).[0] == v o0 + v o2); assert (v (vec_v v10).[1] == v o1 + v o3); let v10h = vec_interleave_high v10 v10 in vec_interleave_high_lemma_uint64_4 v10 v10; assert (v (vec_v v10h).[0] == v (vec_v v10).[1]); let v20 = vec_add_mod v10 v10h in FStar.Math.Lemmas.modulo_lemma (v o0 + v o2 + v o1 + v o3) (pow2 64) val lemma_fmul_r4_normalize51_expand: v2:felem5 4 -> out:felem5 4 -> Lemma (requires (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (uint64xN_v v20).[0] == (uint64xN_v o0).[0] + (uint64xN_v o0).[1] + (uint64xN_v o0).[2] + (uint64xN_v o0).[3] /\ (uint64xN_v v21).[0] == (uint64xN_v o1).[0] + (uint64xN_v o1).[1] + (uint64xN_v o1).[2] + (uint64xN_v o1).[3] /\ (uint64xN_v v22).[0] == (uint64xN_v o2).[0] + (uint64xN_v o2).[1] + (uint64xN_v o2).[2] + (uint64xN_v o2).[3] /\ (uint64xN_v v23).[0] == (uint64xN_v o3).[0] + (uint64xN_v o3).[1] + (uint64xN_v o3).[2] + (uint64xN_v o3).[3] /\ (uint64xN_v v24).[0] == (uint64xN_v o4).[0] + (uint64xN_v o4).[1] + (uint64xN_v o4).[2] + (uint64xN_v o4).[3])) (ensures (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (feval5 v2).[0] == Vec.pfadd (Vec.pfadd (Vec.pfadd (feval5 out).[0] (feval5 out).[1]) (feval5 out).[2]) (feval5 out).[3]))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305.Field32xN.Lemmas2.fst.checked", "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "Hacl.Poly1305.Field32xN.Lemmas0.fst.checked", "Hacl.Impl.Poly1305.Lemmas.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Field32xN.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": "Vec" }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN.Lemmas2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN.Lemmas1", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN.Lemmas0", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": 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": 0, "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v2: Hacl.Spec.Poly1305.Field32xN.felem5 4 -> out: Hacl.Spec.Poly1305.Field32xN.felem5 4 -> FStar.Pervasives.Lemma (requires (let _ = v2 in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ v20 v21 v22 v23 v24 = _ in let _ = out in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ o0 o1 o2 o3 o4 = _ in (Hacl.Spec.Poly1305.Field32xN.uint64xN_v v20).[ 0 ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o0).[ 0 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o0).[ 1 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o0).[ 2 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o0).[ 3 ] /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v v21).[ 0 ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o1).[ 0 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o1).[ 1 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o1).[ 2 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o1).[ 3 ] /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v v22).[ 0 ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o2).[ 0 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o2).[ 1 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o2).[ 2 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o2).[ 3 ] /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v v23).[ 0 ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o3).[ 0 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o3).[ 1 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o3).[ 2 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o3).[ 3 ] /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v v24).[ 0 ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o4).[ 0 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o4).[ 1 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o4).[ 2 ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v o4).[ 3 ]) <: Type0) <: Type0)) (ensures (let _ = v2 in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ _ = _ in let _ = out in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ _ = _ in (Hacl.Spec.Poly1305.Field32xN.feval5 v2).[ 0 ] == Hacl.Spec.Poly1305.Vec.pfadd (Hacl.Spec.Poly1305.Vec.pfadd (Hacl.Spec.Poly1305.Vec.pfadd (Hacl.Spec.Poly1305.Field32xN.feval5 out).[ 0 ] (Hacl.Spec.Poly1305.Field32xN.feval5 out).[ 1 ]) (Hacl.Spec.Poly1305.Field32xN.feval5 out).[ 2 ]) (Hacl.Spec.Poly1305.Field32xN.feval5 out).[ 3 ]) <: Type0) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Field32xN.felem5", "Lib.IntTypes.uint64", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.Sequence.op_String_Access", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Spec.Poly1305.Field32xN.feval5", "Prims.op_Modulus", "Prims.op_Addition", "Hacl.Spec.Poly1305.Vec.prime", "Prims.unit", "FStar.Calc.calc_finish", "Hacl.Spec.Poly1305.Field32xN.as_nat5", "FStar.Pervasives.Native.Mktuple5", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_plus_distr_l", "FStar.Math.Lemmas.modulo_distributivity", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "Hacl.Spec.Poly1305.Field32xN.tup64_5" ]
[]
false
false
true
false
false
let lemma_fmul_r4_normalize51_expand v2 out =
let v20, v21, v22, v23, v24 = as_tup64_i v2 0 in let o0, o1, o2, o3, o4 = out in calc ( == ) { as_nat5 (v20, v21, v22, v23, v24) % Vec.prime; ( == ) { () } (as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1) + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1)) (as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) Vec.prime } ((as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1)) % Vec.prime + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; ( == ) { FStar.Math.Lemmas.modulo_distributivity (as_nat5 (as_tup64_i out 0)) (as_nat5 (as_tup64_i out 1)) Vec.prime } (((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime + as_nat5 (as_tup64_i out 2)) (as_nat5 (as_tup64_i out 3)) Vec.prime } ((((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime + as_nat5 (as_tup64_i out 2)) % Vec.prime + as_nat5 (as_tup64_i out 3)) % Vec.prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime) (as_nat5 (as_tup64_i out 2)) Vec.prime } ((((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime + (feval5 out).[ 2 ]) % Vec.prime + as_nat5 (as_tup64_i out 3)) % Vec.prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r ((((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime + (feval5 out).[ 2 ]) % Vec.prime) (as_nat5 (as_tup64_i out 3)) Vec.prime } ((((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime + (feval5 out).[ 2 ]) % Vec.prime + (feval5 out).[ 3 ]) % Vec.prime; }; assert ((feval5 v2).[ 0 ] == ((((feval5 out).[ 0 ] + (feval5 out).[ 1 ]) % Vec.prime + (feval5 out).[ 2 ]) % Vec.prime + (feval5 out).[ 3 ]) % Vec.prime)
false
LList.Invariant.fst
LList.Invariant.intro_llist_nil
val intro_llist_nil (a:Type) : SteelT unit emp (fun _ -> llist (null_llist #a) [])
val intro_llist_nil (a:Type) : SteelT unit emp (fun _ -> llist (null_llist #a) [])
let intro_llist_nil a = rewrite_slprop emp (llist null_llist []) (fun m -> pure_interp (null_llist #a == null_llist) m; norm_spec [delta; zeta] ((llist (null_llist #a) [])))
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 64, "end_line": 70, "start_col": 0, "start_line": 67 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d } let hd l = Cons?.hd l let tl l = Cons?.tl l let null_llist (#a:Type) = null let ptr_eq (#a:Type) (x y:t a) = admit() //////////////////////////////////////////////////////////////////////////////// // Main llist invariant //////////////////////////////////////////////////////////////////////////////// let rec llist' (#a:Type) (ptr:t a) (l:list (cell a)) : Tot vprop (decreases l) = match l with | [] -> pure (ptr == null_llist) | hd :: tl -> pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star` llist' (next hd) tl let llist = llist' (* Helper lemmas/rewritings *)
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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: Type0 -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.emp", "LList.Invariant.llist", "LList.Invariant.null_llist", "Prims.Nil", "LList.Invariant.cell", "Steel.Memory.mem", "FStar.Pervasives.norm_spec", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta", "FStar.Pervasives.zeta", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Memory.pure_interp", "Prims.eq2", "LList.Invariant.t" ]
[]
false
true
false
false
false
let intro_llist_nil a =
rewrite_slprop emp (llist null_llist []) (fun m -> pure_interp (null_llist #a == null_llist) m; norm_spec [delta; zeta] ((llist (null_llist #a) [])))
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_64
val proj_g_pow2_64:S.proj_point
val proj_g_pow2_64:S.proj_point
let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 44, "start_col": 0, "start_line": 37 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //-----------------
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Spec.K256.PointOps.proj_point
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple3", "Spec.K256.PointOps.felem" ]
[]
false
false
false
true
false
let proj_g_pow2_64:S.proj_point =
[@@ inline_let ]let rX:S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@@ inline_let ]let rY:S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@@ inline_let ]let rZ:S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_point_to_list
val proj_point_to_list: p:S.proj_point -> x:list uint64{FStar.List.Tot.length x = 15 /\ mk_to_k256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val proj_point_to_list: p:S.proj_point -> x:list uint64{FStar.List.Tot.length x = 15 /\ mk_to_k256_comm_monoid.BE.linv (Seq.seq_of_list x)}
let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 29, "start_col": 0, "start_line": 27 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
p: Spec.K256.PointOps.proj_point -> x: Prims.list Lib.IntTypes.uint64 { FStar.List.Tot.Base.length x = 15 /\ Mkto_comm_monoid?.linv Hacl.Impl.K256.Group.mk_to_k256_comm_monoid (FStar.Seq.Base.seq_of_list x) }
Prims.Tot
[ "total" ]
[]
[ "Spec.K256.PointOps.proj_point", "Hacl.Spec.K256.PrecompTable.proj_point_to_list", "Prims.unit", "Hacl.Spec.K256.PrecompTable.proj_point_to_list_lemma", "Prims.list", "Lib.IntTypes.uint64", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.Impl.K256.Group.mk_to_k256_comm_monoid", "FStar.Seq.Base.seq_of_list" ]
[]
false
false
false
false
false
let proj_point_to_list p =
SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.lemma_refl
val lemma_refl: x:S.proj_point -> Lemma (S.mk_k256_concrete_ops.SE.to.SE.refl x == mk_to_k256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
val lemma_refl: x:S.proj_point -> Lemma (S.mk_k256_concrete_ops.SE.to.SE.refl x == mk_to_k256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
let lemma_refl x = SPTK.proj_point_to_list_lemma x
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 32, "start_col": 0, "start_line": 31 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
x: Spec.K256.PointOps.proj_point -> FStar.Pervasives.Lemma (ensures Mkto_comm_monoid?.refl (Mkconcrete_ops?.to Spec.K256.mk_k256_concrete_ops) x == Mkto_comm_monoid?.refl Hacl.Impl.K256.Group.mk_to_k256_comm_monoid (FStar.Seq.Base.seq_of_list (Hacl.K256.PrecompTable.proj_point_to_list x)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.proj_point", "Hacl.Spec.K256.PrecompTable.proj_point_to_list_lemma", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_refl x =
SPTK.proj_point_to_list_lemma x
false
LList.Invariant.fst
LList.Invariant.intro_llist_cons
val intro_llist_cons (#a:Type) (ptr:t a) (hd: cell a) (tl: list (cell a)) : Steel unit (pts_to ptr full_perm hd `star` llist (next hd) tl) (fun _ -> llist ptr (hd::tl)) (requires fun _ -> ~ (is_null ptr)) (ensures fun _ _ _ -> True)
val intro_llist_cons (#a:Type) (ptr:t a) (hd: cell a) (tl: list (cell a)) : Steel unit (pts_to ptr full_perm hd `star` llist (next hd) tl) (fun _ -> llist ptr (hd::tl)) (requires fun _ -> ~ (is_null ptr)) (ensures fun _ _ _ -> True)
let intro_llist_cons #a ptr hd tl = intro_pure (ptr =!= null_llist); rewrite_slprop (pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star` llist' (next hd) tl) (llist ptr (hd::tl)) (fun _ -> norm_spec [delta;zeta] (llist ptr (hd::tl)))
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 70, "end_line": 78, "start_col": 0, "start_line": 72 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d } let hd l = Cons?.hd l let tl l = Cons?.tl l let null_llist (#a:Type) = null let ptr_eq (#a:Type) (x y:t a) = admit() //////////////////////////////////////////////////////////////////////////////// // Main llist invariant //////////////////////////////////////////////////////////////////////////////// let rec llist' (#a:Type) (ptr:t a) (l:list (cell a)) : Tot vprop (decreases l) = match l with | [] -> pure (ptr == null_llist) | hd :: tl -> pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star` llist' (next hd) tl let llist = llist' (* Helper lemmas/rewritings *) let intro_llist_nil a = rewrite_slprop emp (llist null_llist []) (fun m -> pure_interp (null_llist #a == null_llist) m; norm_spec [delta; zeta] ((llist (null_llist #a) [])))
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
ptr: LList.Invariant.t a -> hd: LList.Invariant.cell a -> tl: Prims.list (LList.Invariant.cell a) -> Steel.Effect.Steel Prims.unit
Steel.Effect.Steel
[]
[]
[ "LList.Invariant.t", "LList.Invariant.cell", "Prims.list", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.star", "Steel.Effect.Common.pure", "Prims.l_not", "Prims.eq2", "LList.Invariant.null_llist", "Steel.Reference.pts_to", "Steel.FractionalPermission.full_perm", "LList.Invariant.llist'", "LList.Invariant.next", "LList.Invariant.llist", "Prims.Cons", "Steel.Memory.mem", "FStar.Pervasives.norm_spec", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta", "FStar.Pervasives.zeta", "Prims.Nil", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Effect.Atomic.intro_pure" ]
[]
false
true
false
false
false
let intro_llist_cons #a ptr hd tl =
intro_pure (ptr =!= null_llist); rewrite_slprop (((pure (ptr =!= null_llist)) `star` (pts_to ptr full_perm hd)) `star` (llist' (next hd) tl)) (llist ptr (hd :: tl)) (fun _ -> norm_spec [delta; zeta] (llist ptr (hd :: tl)))
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_128
val proj_g_pow2_128:S.proj_point
val proj_g_pow2_128:S.proj_point
let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 67, "start_col": 0, "start_line": 60 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Spec.K256.PointOps.proj_point
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple3", "Spec.K256.PointOps.felem" ]
[]
false
false
false
true
false
let proj_g_pow2_128:S.proj_point =
[@@ inline_let ]let rX:S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@@ inline_let ]let rY:S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@@ inline_let ]let rZ:S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ)
false
LList.Invariant.fst
LList.Invariant.elim_llist_cons
val elim_llist_cons (#a:Type) (ptr:t a) (hd:cell a) (tl:list (cell a)) : SteelT unit (llist ptr (hd::tl)) (fun _ -> pts_to ptr full_perm hd `star` llist (next hd) tl)
val elim_llist_cons (#a:Type) (ptr:t a) (hd:cell a) (tl:list (cell a)) : SteelT unit (llist ptr (hd::tl)) (fun _ -> pts_to ptr full_perm hd `star` llist (next hd) tl)
let elim_llist_cons #a ptr hd tl = rewrite_slprop (llist ptr (hd::tl)) (pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star` llist' (next hd) tl) (fun _ -> ()); drop (pure (ptr =!= null_llist))
{ "file_name": "share/steel/examples/steel/LList.Invariant.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 34, "end_line": 86, "start_col": 0, "start_line": 80 }
(* Copyright 2020 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. Author(s): N. Swamy, A. Fromherz *) module LList.Invariant open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference module L = FStar.List.Tot #push-options "--__no_positivity" noeq type cell (a: Type0) = { next: ref (cell a); data: a; } #pop-options let next (c:cell 'a) : t 'a = c.next let data (c:cell 'a) : 'a = c.data let mk_cell (n: t 'a) (d:'a) = { next = n; data = d } let hd l = Cons?.hd l let tl l = Cons?.tl l let null_llist (#a:Type) = null let ptr_eq (#a:Type) (x y:t a) = admit() //////////////////////////////////////////////////////////////////////////////// // Main llist invariant //////////////////////////////////////////////////////////////////////////////// let rec llist' (#a:Type) (ptr:t a) (l:list (cell a)) : Tot vprop (decreases l) = match l with | [] -> pure (ptr == null_llist) | hd :: tl -> pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star` llist' (next hd) tl let llist = llist' (* Helper lemmas/rewritings *) let intro_llist_nil a = rewrite_slprop emp (llist null_llist []) (fun m -> pure_interp (null_llist #a == null_llist) m; norm_spec [delta; zeta] ((llist (null_llist #a) []))) let intro_llist_cons #a ptr hd tl = intro_pure (ptr =!= null_llist); rewrite_slprop (pure (ptr =!= null_llist) `star` pts_to ptr full_perm hd `star` llist' (next hd) tl) (llist ptr (hd::tl)) (fun _ -> norm_spec [delta;zeta] (llist ptr (hd::tl)))
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "LList.Invariant.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": false, "full_module": "LList", "short_module": null }, { "abbrev": 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
ptr: LList.Invariant.t a -> hd: LList.Invariant.cell a -> tl: Prims.list (LList.Invariant.cell a) -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "LList.Invariant.t", "LList.Invariant.cell", "Prims.list", "Steel.Effect.Atomic.drop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.pure", "Prims.l_not", "Prims.eq2", "LList.Invariant.null_llist", "Prims.unit", "Steel.Effect.Atomic.rewrite_slprop", "LList.Invariant.llist", "Prims.Cons", "Steel.Effect.Common.star", "Steel.Reference.pts_to", "Steel.FractionalPermission.full_perm", "LList.Invariant.llist'", "LList.Invariant.next", "Steel.Memory.mem" ]
[]
false
true
false
false
false
let elim_llist_cons #a ptr hd tl =
rewrite_slprop (llist ptr (hd :: tl)) (((pure (ptr =!= null_llist)) `star` (pts_to ptr full_perm hd)) `star` (llist' (next hd) tl)) (fun _ -> ()); drop (pure (ptr =!= null_llist))
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.lemma_proj_g_pow2_64_eval
val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64)
val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64)
let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 56, "start_col": 0, "start_line": 49 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.Exponentiation.exp_pow2 Spec.K256.mk_k256_concrete_ops Spec.K256.PointOps.g 64 == Hacl.K256.PrecompTable.proj_g_pow2_64)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Spec.K256.PointOps.felem", "FStar.Pervasives.assert_norm", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.normalize_term_spec", "Spec.K256.PointOps.proj_point", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec", "Spec.K256.mk_k256_concrete_ops", "Spec.K256.PointOps.g", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.normalize_term", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2" ]
[]
false
false
true
false
false
let lemma_proj_g_pow2_64_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX:S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY:S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ:S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
false
Selectors.LList2.fst
Selectors.LList2.nllist_of_llist0
val nllist_of_llist0 (#opened: _) (#a: Type0) (r: t a) : SteelGhost (Ghost.erased nat) opened (llist0 r) (fun res -> nllist a res r) (fun _ -> True) (fun h0 res h1 -> h0 (llist0 r) == h1 (nllist a res r))
val nllist_of_llist0 (#opened: _) (#a: Type0) (r: t a) : SteelGhost (Ghost.erased nat) opened (llist0 r) (fun res -> nllist a res r) (fun _ -> True) (fun h0 res h1 -> h0 (llist0 r) == h1 (nllist a res r))
let nllist_of_llist0 (#opened: _) (#a: Type0) (r: t a) : SteelGhost (Ghost.erased nat) opened (llist0 r) (fun res -> nllist a res r) (fun _ -> True) (fun h0 res h1 -> h0 (llist0 r) == h1 (nllist a res r) ) = if is_null r then begin let res = Ghost.hide 0 in change_equal_slprop (llist0 r) (nllist a res r); res end else begin change_equal_slprop (llist0 r) ((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r); elim_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r); let gk : normal (Ghost.erased (t_of (vptr r))) = elim_vdep (vptr r) (llist_vdep r) in let res = Ghost.hide (Ghost.reveal (Ghost.reveal gk).tail_fuel + 1) in intro_vrefine (vptr r) (v_c res r); intro_vdep (vptr r `vrefine` v_c res r) (llist_vdep r (Ghost.reveal gk)) (v_c_dep res r (nllist a)); intro_vrewrite ((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) (v_c_l_rewrite res r (nllist a)); nllist_eq_not_null a res r; change_equal_slprop (((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) `vrewrite` v_c_l_rewrite res r (nllist a)) (nllist a res r); res end
{ "file_name": "share/steel/examples/steel/Selectors.LList2.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 148, "start_col": 0, "start_line": 111 }
module Selectors.LList2 open Steel.FractionalPermission module Mem = Steel.Memory #push-options "--__no_positivity" noeq type cell (a: Type0) = { tail_fuel: Ghost.erased nat; next: ref (cell a); data: a; } #pop-options let next #a (c:cell a) : t a = c.next let data #a (c:cell a) : a = c.data let mk_cell #a (n: t a) (d:a) = { tail_fuel = Ghost.hide 0; next = n; data = d } let null_llist #a = null let is_null #a ptr = is_null ptr let v_null_rewrite (a: Type0) (_: t_of emp) : GTot (list a) = [] let v_c (n: Ghost.erased nat) (#a: Type0) (r: t a) (c: normal (t_of (vptr r))) : GTot prop = (Ghost.reveal c.tail_fuel < Ghost.reveal n) == true // to ensure vprop termination let v_c_dep (n: Ghost.erased nat) (#a: Type0) (r: t a) (nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a))) (c: normal (t_of (vrefine (vptr r) (v_c n r)))) : Tot vprop = nllist c.tail_fuel c.next let v_c_l_rewrite (n: Ghost.erased nat) (#a: Type0) (r: t a) (nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a))) (res: normal (t_of ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r nllist))) : Tot (list a) = let (| c, l |) = res in c.data :: l let rec nllist (a: Type0) (n: Ghost.erased nat) (r: t a) : Pure vprop (requires True) (ensures (fun y -> t_of y == list a)) (decreases (Ghost.reveal n)) = if is_null r then emp `vrewrite` v_null_rewrite a else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a) let nllist_eq_not_null (a: Type0) (n: Ghost.erased nat) (r: t a) : Lemma (requires (is_null r == false)) (ensures ( nllist a n r == ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a) )) = assert_norm (nllist a n r == begin if is_null r then emp `vrewrite` v_null_rewrite a else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a) end ) let llist_vdep (#a: Type0) (r: t a) (c: normal (t_of (vptr r))) : Tot vprop = nllist a c.tail_fuel c.next let llist_vrewrite (#a: Type0) (r: t a) (cl: normal (t_of (vptr r `vdep` llist_vdep r))) : GTot (list a) = (dfst cl).data :: dsnd cl let llist0 (#a: Type0) (r: t a) : Pure vprop (requires True) (ensures (fun y -> t_of y == list a)) = if is_null r then emp `vrewrite` v_null_rewrite a else (vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Selectors.LList2.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Selectors", "short_module": null }, { "abbrev": false, "full_module": "Selectors", "short_module": null }, { "abbrev": 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: Selectors.LList2.t a -> Steel.Effect.Atomic.SteelGhost (FStar.Ghost.erased Prims.nat)
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "Selectors.LList2.t", "Selectors.LList2.is_null", "FStar.Ghost.erased", "Prims.nat", "Prims.unit", "Steel.Effect.Atomic.change_equal_slprop", "Selectors.LList2.llist0", "Selectors.LList2.nllist", "FStar.Ghost.hide", "Prims.bool", "Steel.Effect.Common.vrewrite", "Steel.Effect.Common.vdep", "Steel.Effect.Common.vrefine", "Steel.Reference.vptr", "Selectors.LList2.cell", "Selectors.LList2.v_c", "Selectors.LList2.v_c_dep", "Prims.list", "Selectors.LList2.v_c_l_rewrite", "Selectors.LList2.nllist_eq_not_null", "Steel.Effect.Atomic.intro_vrewrite", "Steel.Effect.Atomic.intro_vdep", "Selectors.LList2.llist_vdep", "FStar.Ghost.reveal", "Steel.Effect.Atomic.intro_vrefine", "Prims.op_Addition", "Selectors.LList2.__proj__Mkcell__item__tail_fuel", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.delta_only", "FStar.Pervasives.delta_qualifier", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "FStar.Pervasives.simplify", "Steel.Effect.Common.t_of", "Steel.Effect.Common.VUnit", "Steel.Reference.vptr'", "Steel.FractionalPermission.full_perm", "Steel.Effect.Atomic.elim_vdep", "Steel.Effect.Atomic.elim_vrewrite", "Selectors.LList2.llist_vrewrite", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_True", "Prims.eq2", "Steel.Effect.Common.normal" ]
[]
false
true
false
false
false
let nllist_of_llist0 (#opened: _) (#a: Type0) (r: t a) : SteelGhost (Ghost.erased nat) opened (llist0 r) (fun res -> nllist a res r) (fun _ -> True) (fun h0 res h1 -> h0 (llist0 r) == h1 (nllist a res r)) =
if is_null r then let res = Ghost.hide 0 in change_equal_slprop (llist0 r) (nllist a res r); res else (change_equal_slprop (llist0 r) (((vptr r) `vdep` (llist_vdep r)) `vrewrite` (llist_vrewrite r)); elim_vrewrite ((vptr r) `vdep` (llist_vdep r)) (llist_vrewrite r); let gk:normal (Ghost.erased (t_of (vptr r))) = elim_vdep (vptr r) (llist_vdep r) in let res = Ghost.hide (Ghost.reveal (Ghost.reveal gk).tail_fuel + 1) in intro_vrefine (vptr r) (v_c res r); intro_vdep ((vptr r) `vrefine` (v_c res r)) (llist_vdep r (Ghost.reveal gk)) (v_c_dep res r (nllist a)); intro_vrewrite (((vptr r) `vrefine` (v_c res r)) `vdep` (v_c_dep res r (nllist a))) (v_c_l_rewrite res r (nllist a)); nllist_eq_not_null a res r; change_equal_slprop ((((vptr r) `vrefine` (v_c res r)) `vdep` (v_c_dep res r (nllist a))) `vrewrite` (v_c_l_rewrite res r (nllist a))) (nllist a res r); res)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_192
val proj_g_pow2_192:S.proj_point
val proj_g_pow2_192:S.proj_point
let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 90, "start_col": 0, "start_line": 83 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Spec.K256.PointOps.proj_point
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple3", "Spec.K256.PointOps.felem" ]
[]
false
false
false
true
false
let proj_g_pow2_192:S.proj_point =
[@@ inline_let ]let rX:S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@@ inline_let ]let rY:S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@@ inline_let ]let rZ:S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ)
false
Hacl.HKDF.fst
Hacl.HKDF.mk_expand
val mk_expand: a: fixed_len_alg -> hmac: Hacl.HMAC.compute_st a -> expand_st a
val mk_expand: a: fixed_len_alg -> hmac: Hacl.HMAC.compute_st a -> expand_st a
let mk_expand a hmac okm prk prklen info infolen len = let tlen = Hash.Definitions.hash_len a in let n = len /. tlen in Math.Lemmas.lemma_div_mod (v len) (v tlen); hmac_input_fits a; [@inline_let] let okm: B.lbuffer uint8 len = okm in [@inline_let] let prk: B.lbuffer uint8 prklen = prk in [@inline_let] let info: B.lbuffer uint8 infolen = info in let output: B.lbuffer uint8 (n *! tlen) = B.sub okm 0ul (n *! tlen) in push_frame (); let text = B.create (tlen +! infolen +! 1ul) (u8 0) in let text0: B.lbuffer uint8 (infolen +! 1ul) = B.sub text tlen (infolen +! 1ul) in let tag = B.sub text 0ul tlen in let ctr = B.sub text (tlen +! infolen) 1ul in B.copy (B.sub text tlen infolen) info; [@inline_let] let a_spec = a_spec a in [@inline_let] let refl h (i:size_nat{i <= v n}) : GTot (a_spec i) = if i = 0 then FStar.Seq.empty #uint8 else B.as_seq h tag in [@inline_let] let footprint (i:size_nat{i <= v n}) : GTot LB.(l:loc{loc_disjoint l (B.loc output) /\ address_liveness_insensitive_locs `loc_includes` l}) = LB.loc_union (B.loc tag) (B.loc ctr) in [@inline_let] let spec h0 : GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1) & Seq.lseq uint8 (v tlen)) = expand_loop a (B.as_seq h0 prk) (B.as_seq h0 info) (v n) in let h0 = ST.get () in B.fill_blocks h0 tlen n output a_spec refl footprint spec (fun i -> ctr.(0ul) <- Lib.IntTypes.cast U8 PUB (i +! 1ul); let h1 = ST.get() in if i = 0ul then begin Seq.eq_intro (B.as_seq h1 text0) (refl h1 (v i) @| B.as_seq h0 info @| Seq.create 1 (u8 (v i + 1))); hmac tag prk prklen text0 (infolen +! 1ul) // let h2 = ST.get() in // assert (B.as_seq h2 tag == // Spec.Agile.HMAC.hmac a (B.as_seq h0 prk) // (FStar.Seq.empty @| B.as_seq h0 info @| Seq.create 1 (u8 (v i + 1)))); // assert (let _, t = spec h0 0 (FStar.Seq.empty #uint8) in B.as_seq h2 tag == t) end else begin Seq.eq_intro (B.as_seq h1 text) (refl h1 (v i) @| B.as_seq h0 info @| Seq.create 1 (u8 (v i + 1))); hmac tag prk prklen text (tlen +! infolen +! 1ul) // let h2 = ST.get() in // assert (B.as_seq h2 tag == // Spec.Agile.HMAC.hmac a (B.as_seq h0 prk) // (B.as_seq h1 tag @| B.as_seq h0 info @| Seq.create 1 (u8 (v i + 1)))); // assert (let _, t = spec h0 (v i) (B.as_seq h tag) in B.as_seq h2 tag == t) end; Seq.unfold_generate_blocks (v tlen) (v n) a_spec (spec h0) (FStar.Seq.empty #uint8) (v i); //assert (v (i *! tlen) + v tlen <= v (n *! tlen)); B.copy (B.sub output (i *! tlen) tlen) tag // let h3 = ST.get() in // assert ( // footprint (v i + 1) `LB.loc_includes` footprint (v i) /\ // LB.modifies (LB.loc_union (footprint (v i + 1)) (B.loc block)) h h3); //assert ( // let s, b = spec h0 (v i) (refl h (v i)) in // refl h3 (v i + 1) == s /\ as_seq h3 block == b) ); let h1 = ST.get () in if n *! tlen <. len then begin ctr.(0ul) <- Lib.IntTypes.cast U8 PUB (n +! 1ul); let h2 = ST.get() in if n = 0ul then begin Seq.eq_intro (B.as_seq h2 text0) (refl h1 (v n) @| B.as_seq h0 info @| Seq.create 1 (u8 (v n + 1))); hmac tag prk prklen text0 (infolen +! 1ul) end else begin Seq.eq_intro (B.as_seq h2 text) (refl h1 (v n) @| B.as_seq h0 info @| Seq.create 1 (u8 (v n + 1))); hmac tag prk prklen text (tlen +! infolen +! 1ul) end; let block = B.sub okm (n *! tlen) (len -! (n *! tlen)) in B.copy block (B.sub tag 0ul (len -! (n *! tlen))) end; let h4 = ST.get() in assert ( let tag', output' = Seq.generate_blocks (v tlen) (v n) (v n) a_spec (spec h0) (FStar.Seq.empty #uint8) in Seq.equal (B.as_seq h4 okm) (output' @| Seq.sub (B.as_seq h4 tag) 0 (v len - v n * v tlen))); pop_frame ()
{ "file_name": "code/hkdf/Hacl.HKDF.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 169, "start_col": 0, "start_line": 60 }
module Hacl.HKDF open FStar.Seq module B = Lib.Buffer module LB = LowStar.Buffer open Spec.Hash.Definitions open Spec.Agile.HKDF open FStar.Mul open FStar.HyperStack open FStar.HyperStack.ST open Lib.Buffer friend Spec.Agile.HKDF friend Lib.IntTypes module Seq = Lib.Sequence // TODO: proofs break mysteriously when not befriending Lib.IntTypes and // declassifying uint8; investigate // assume val declassify8: squash (uint8 == UInt8.t) module ST = FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" let mk_extract a hmac prk salt saltlen ikm ikmlen = hmac prk salt saltlen ikm ikmlen val hmac_input_fits: a:fixed_len_alg -> Lemma ((pow2 32 + block_length a) `less_than_max_input_length` a) let hmac_input_fits a = allow_inversion fixed_len_alg; match a with | MD5 -> assert_norm (pow2 32 + block_length MD5 <= Some?.v (max_input_length MD5)) | SHA1 -> assert_norm (pow2 32 + block_length SHA1 <= Some?.v (max_input_length SHA1)) | SHA2_224 -> assert_norm (pow2 32 + block_length SHA2_224 <= Some?.v (max_input_length SHA2_224)) | SHA2_256 -> assert_norm (pow2 32 + block_length SHA2_256 <= Some?.v (max_input_length SHA2_256)) | SHA2_384 -> assert_norm (pow2 32 + block_length SHA2_384 <= Some?.v (max_input_length SHA2_384)) | SHA2_512 -> assert_norm (pow2 32 + block_length SHA2_512 <= Some?.v (max_input_length SHA2_512)) | Blake2S -> assert_norm (pow2 32 + block_length Blake2S <= Some?.v (max_input_length Blake2S)) | Blake2B -> assert_norm (pow2 32 + block_length Blake2B <= Some?.v (max_input_length Blake2B)) | SHA3_224 -> () | SHA3_256 -> () | SHA3_384 -> () | SHA3_512 -> () #push-options "--z3rlimit 300"
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HKDF.fst.checked", "Spec.Agile.HKDF.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fst.checked", "Lib.Buffer.fsti.checked", "Hacl.HMAC.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.HKDF.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Lib.Buffer", "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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": 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": 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": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.fixed_len_alg -> hmac: Hacl.HMAC.compute_st a -> Hacl.HKDF.expand_st a
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "Hacl.HMAC.compute_st", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.pub_uint32", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Prims._assert", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star", "Lib.Sequence.equal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Seq.Base.op_At_Bar", "Lib.Sequence.sub", "Prims.op_Subtraction", "FStar.Pervasives.Native.tuple2", "Prims.op_Multiply", "Lib.Sequence.generate_blocks", "FStar.Seq.Base.empty", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.IntTypes.op_Less_Dot", "Lib.IntTypes.op_Star_Bang", "Lib.Buffer.copy", "Lib.IntTypes.op_Subtraction_Bang", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.sub", "Lib.IntTypes.mul", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Prims.op_Equality", "FStar.UInt32.t", "Lib.IntTypes.op_Plus_Bang", "Lib.Sequence.eq_intro", "Lib.IntTypes.add", "FStar.UInt32.uint_to_t", "Lib.Sequence.create", "Lib.IntTypes.u8", "Prims.op_Addition", "Prims.bool", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.cast", "Lib.Buffer.fill_blocks", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.unfold_generate_blocks", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.pow2", "Lib.Sequence.lseq", "Spec.Agile.HKDF.expand_loop", "Lib.IntTypes.size_nat", "LowStar.Monotonic.Buffer.loc", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_disjoint", "Lib.Buffer.loc", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "LowStar.Monotonic.Buffer.loc_union", "FStar.Integers.int_t", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "Prims.op_GreaterThanOrEqual", "Spec.Agile.HKDF.a_spec", "Lib.Buffer.create", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.HKDF.hmac_input_fits", "FStar.Math.Lemmas.lemma_div_mod", "Lib.IntTypes.op_Slash_Dot", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Spec.Hash.Definitions.hash_length", "Hacl.Hash.Definitions.hash_len" ]
[]
false
false
false
false
false
let mk_expand a hmac okm prk prklen info infolen len =
let tlen = Hash.Definitions.hash_len a in let n = len /. tlen in Math.Lemmas.lemma_div_mod (v len) (v tlen); hmac_input_fits a; [@@ inline_let ]let okm:B.lbuffer uint8 len = okm in [@@ inline_let ]let prk:B.lbuffer uint8 prklen = prk in [@@ inline_let ]let info:B.lbuffer uint8 infolen = info in let output:B.lbuffer uint8 (n *! tlen) = B.sub okm 0ul (n *! tlen) in push_frame (); let text = B.create (tlen +! infolen +! 1ul) (u8 0) in let text0:B.lbuffer uint8 (infolen +! 1ul) = B.sub text tlen (infolen +! 1ul) in let tag = B.sub text 0ul tlen in let ctr = B.sub text (tlen +! infolen) 1ul in B.copy (B.sub text tlen infolen) info; [@@ inline_let ]let a_spec = a_spec a in [@@ inline_let ]let refl h (i: size_nat{i <= v n}) : GTot (a_spec i) = if i = 0 then FStar.Seq.empty #uint8 else B.as_seq h tag in [@@ inline_let ]let footprint (i: size_nat{i <= v n}) : GTot LB.(l: loc{loc_disjoint l (B.loc output) /\ address_liveness_insensitive_locs `loc_includes` l}) = LB.loc_union (B.loc tag) (B.loc ctr) in [@@ inline_let ]let spec h0 : GTot (i: size_nat{i < v n} -> a_spec i -> a_spec (i + 1) & Seq.lseq uint8 (v tlen)) = expand_loop a (B.as_seq h0 prk) (B.as_seq h0 info) (v n) in let h0 = ST.get () in B.fill_blocks h0 tlen n output a_spec refl footprint spec (fun i -> ctr.(0ul) <- Lib.IntTypes.cast U8 PUB (i +! 1ul); let h1 = ST.get () in if i = 0ul then (Seq.eq_intro (B.as_seq h1 text0) (refl h1 (v i) @| B.as_seq h0 info @| Seq.create 1 (u8 (v i + 1))); hmac tag prk prklen text0 (infolen +! 1ul)) else (Seq.eq_intro (B.as_seq h1 text) (refl h1 (v i) @| B.as_seq h0 info @| Seq.create 1 (u8 (v i + 1))); hmac tag prk prklen text (tlen +! infolen +! 1ul)); Seq.unfold_generate_blocks (v tlen) (v n) a_spec (spec h0) (FStar.Seq.empty #uint8) (v i); B.copy (B.sub output (i *! tlen) tlen) tag); let h1 = ST.get () in if n *! tlen <. len then (ctr.(0ul) <- Lib.IntTypes.cast U8 PUB (n +! 1ul); let h2 = ST.get () in if n = 0ul then (Seq.eq_intro (B.as_seq h2 text0) (refl h1 (v n) @| B.as_seq h0 info @| Seq.create 1 (u8 (v n + 1))); hmac tag prk prklen text0 (infolen +! 1ul)) else (Seq.eq_intro (B.as_seq h2 text) (refl h1 (v n) @| B.as_seq h0 info @| Seq.create 1 (u8 (v n + 1))); hmac tag prk prklen text (tlen +! infolen +! 1ul)); let block = B.sub okm (n *! tlen) (len -! (n *! tlen)) in B.copy block (B.sub tag 0ul (len -! (n *! tlen)))); let h4 = ST.get () in assert (let tag', output' = Seq.generate_blocks (v tlen) (v n) (v n) a_spec (spec h0) (FStar.Seq.empty #uint8) in Seq.equal (B.as_seq h4 okm) (output' @| Seq.sub (B.as_seq h4 tag) 0 (v len - v n * v tlen))); pop_frame ()
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.lemma_proj_g_pow2_128_eval
val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 79, "start_col": 0, "start_line": 72 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.Exponentiation.exp_pow2 Spec.K256.mk_k256_concrete_ops Hacl.K256.PrecompTable.proj_g_pow2_64 64 == Hacl.K256.PrecompTable.proj_g_pow2_128)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Spec.K256.PointOps.felem", "FStar.Pervasives.assert_norm", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.normalize_term_spec", "Spec.K256.PointOps.proj_point", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec", "Spec.K256.mk_k256_concrete_ops", "Hacl.K256.PrecompTable.proj_g_pow2_64", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.normalize_term", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2" ]
[]
false
false
true
false
false
let lemma_proj_g_pow2_128_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX:S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY:S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ:S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_64_list
val proj_g_pow2_64_list:SPTK.point_list
val proj_g_pow2_64_list:SPTK.point_list
let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 117, "start_col": 0, "start_line": 116 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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.Spec.K256.PrecompTable.point_list
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list", "Hacl.K256.PrecompTable.proj_g_pow2_64" ]
[]
false
false
false
true
false
let proj_g_pow2_64_list:SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_192_list
val proj_g_pow2_192_list:SPTK.point_list
val proj_g_pow2_192_list:SPTK.point_list
let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 125, "start_col": 0, "start_line": 124 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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.Spec.K256.PrecompTable.point_list
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list", "Hacl.K256.PrecompTable.proj_g_pow2_192" ]
[]
false
false
false
true
false
let proj_g_pow2_192_list:SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_128_list
val proj_g_pow2_128_list:SPTK.point_list
val proj_g_pow2_128_list:SPTK.point_list
let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 121, "start_col": 0, "start_line": 120 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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.Spec.K256.PrecompTable.point_list
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list", "Hacl.K256.PrecompTable.proj_g_pow2_128" ]
[]
false
false
false
true
false
let proj_g_pow2_128_list:SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_192_lemma
val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 165, "start_col": 0, "start_line": 161 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.to_aff_point Hacl.K256.PrecompTable.proj_g_pow2_192 == Hacl.K256.PrecompTable.pow_point (Prims.pow2 192) Hacl.K256.PrecompTable.g_aff)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable256.a_pow2_192_lemma", "Spec.K256.PointOps.proj_point", "Spec.K256.mk_k256_concrete_ops", "Spec.K256.PointOps.g", "Hacl.K256.PrecompTable.lemma_proj_g_pow2_64_eval", "Hacl.K256.PrecompTable.lemma_proj_g_pow2_128_eval", "Hacl.K256.PrecompTable.lemma_proj_g_pow2_192_eval" ]
[]
true
false
true
false
false
let proj_g_pow2_192_lemma () =
lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_128_lseq_lemma
val proj_g_pow2_128_lseq_lemma: unit -> Lemma (point_inv_lseq proj_g_pow2_128_lseq /\ S.to_aff_point (point_eval_lseq proj_g_pow2_128_lseq) == g_pow2_128)
val proj_g_pow2_128_lseq_lemma: unit -> Lemma (point_inv_lseq proj_g_pow2_128_lseq /\ S.to_aff_point (point_eval_lseq proj_g_pow2_128_lseq) == g_pow2_128)
let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 177, "start_col": 0, "start_line": 174 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Hacl.Impl.K256.Point.point_inv_lseq Hacl.K256.PrecompTable.proj_g_pow2_128_lseq /\ Spec.K256.PointOps.to_aff_point (Hacl.Impl.K256.Point.point_eval_lseq Hacl.K256.PrecompTable.proj_g_pow2_128_lseq ) == Hacl.K256.PrecompTable.g_pow2_128)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.K256.PrecompTable.proj_point_to_list_lemma", "Hacl.K256.PrecompTable.proj_g_pow2_128", "Hacl.K256.PrecompTable.proj_g_pow2_128_lemma", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list" ]
[]
true
false
true
false
false
let proj_g_pow2_128_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_64_lemma
val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 146, "start_col": 0, "start_line": 144 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.to_aff_point Hacl.K256.PrecompTable.proj_g_pow2_64 == Hacl.K256.PrecompTable.pow_point (Prims.pow2 64) Hacl.K256.PrecompTable.g_aff)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable256.a_pow2_64_lemma", "Spec.K256.PointOps.proj_point", "Spec.K256.mk_k256_concrete_ops", "Spec.K256.PointOps.g", "Hacl.K256.PrecompTable.lemma_proj_g_pow2_64_eval" ]
[]
true
false
true
false
false
let proj_g_pow2_64_lemma () =
lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_192_lseq_lemma
val proj_g_pow2_192_lseq_lemma: unit -> Lemma (point_inv_lseq proj_g_pow2_192_lseq /\ S.to_aff_point (point_eval_lseq proj_g_pow2_192_lseq) == g_pow2_192)
val proj_g_pow2_192_lseq_lemma: unit -> Lemma (point_inv_lseq proj_g_pow2_192_lseq /\ S.to_aff_point (point_eval_lseq proj_g_pow2_192_lseq) == g_pow2_192)
let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 183, "start_col": 0, "start_line": 180 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Hacl.Impl.K256.Point.point_inv_lseq Hacl.K256.PrecompTable.proj_g_pow2_192_lseq /\ Spec.K256.PointOps.to_aff_point (Hacl.Impl.K256.Point.point_eval_lseq Hacl.K256.PrecompTable.proj_g_pow2_192_lseq ) == Hacl.K256.PrecompTable.g_pow2_192)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.K256.PrecompTable.proj_point_to_list_lemma", "Hacl.K256.PrecompTable.proj_g_pow2_192", "Hacl.K256.PrecompTable.proj_g_pow2_192_lemma", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list" ]
[]
true
false
true
false
false
let proj_g_pow2_192_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_64_lseq_lemma
val proj_g_pow2_64_lseq_lemma: unit -> Lemma (point_inv_lseq proj_g_pow2_64_lseq /\ S.to_aff_point (point_eval_lseq proj_g_pow2_64_lseq) == g_pow2_64)
val proj_g_pow2_64_lseq_lemma: unit -> Lemma (point_inv_lseq proj_g_pow2_64_lseq /\ S.to_aff_point (point_eval_lseq proj_g_pow2_64_lseq) == g_pow2_64)
let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 171, "start_col": 0, "start_line": 168 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Hacl.Impl.K256.Point.point_inv_lseq Hacl.K256.PrecompTable.proj_g_pow2_64_lseq /\ Spec.K256.PointOps.to_aff_point (Hacl.Impl.K256.Point.point_eval_lseq Hacl.K256.PrecompTable.proj_g_pow2_64_lseq ) == Hacl.K256.PrecompTable.g_pow2_64)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.K256.PrecompTable.proj_point_to_list_lemma", "Hacl.K256.PrecompTable.proj_g_pow2_64", "Hacl.K256.PrecompTable.proj_g_pow2_64_lemma", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list" ]
[]
true
false
true
false
false
let proj_g_pow2_64_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_64_lseq
val proj_g_pow2_64_lseq : LSeq.lseq uint64 15
val proj_g_pow2_64_lseq : LSeq.lseq uint64 15
let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 130, "start_col": 0, "start_line": 128 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Lib.Sequence.lseq Lib.IntTypes.uint64 15
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq_of_list", "Lib.IntTypes.uint64", "Hacl.K256.PrecompTable.proj_g_pow2_64_list", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list", "Hacl.K256.PrecompTable.proj_g_pow2_64", "Lib.Sequence.lseq" ]
[]
false
false
false
false
false
let proj_g_pow2_64_lseq:LSeq.lseq uint64 15 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_128_lemma
val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 155, "start_col": 0, "start_line": 152 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.to_aff_point Hacl.K256.PrecompTable.proj_g_pow2_128 == Hacl.K256.PrecompTable.pow_point (Prims.pow2 128) Hacl.K256.PrecompTable.g_aff)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable256.a_pow2_128_lemma", "Spec.K256.PointOps.proj_point", "Spec.K256.mk_k256_concrete_ops", "Spec.K256.PointOps.g", "Hacl.K256.PrecompTable.lemma_proj_g_pow2_64_eval", "Hacl.K256.PrecompTable.lemma_proj_g_pow2_128_eval" ]
[]
true
false
true
false
false
let proj_g_pow2_128_lemma () =
lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_192_lseq
val proj_g_pow2_192_lseq : LSeq.lseq uint64 15
val proj_g_pow2_192_lseq : LSeq.lseq uint64 15
let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 138, "start_col": 0, "start_line": 136 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Lib.Sequence.lseq Lib.IntTypes.uint64 15
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq_of_list", "Lib.IntTypes.uint64", "Hacl.K256.PrecompTable.proj_g_pow2_192_list", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list", "Hacl.K256.PrecompTable.proj_g_pow2_192", "Lib.Sequence.lseq" ]
[]
false
false
false
false
false
let proj_g_pow2_192_lseq:LSeq.lseq uint64 15 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.lemma_proj_g_pow2_192_eval
val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 102, "start_col": 0, "start_line": 95 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.Exponentiation.exp_pow2 Spec.K256.mk_k256_concrete_ops Hacl.K256.PrecompTable.proj_g_pow2_128 64 == Hacl.K256.PrecompTable.proj_g_pow2_192)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Spec.K256.PointOps.felem", "FStar.Pervasives.assert_norm", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.normalize_term_spec", "Spec.K256.PointOps.proj_point", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec", "Spec.K256.mk_k256_concrete_ops", "Hacl.K256.PrecompTable.proj_g_pow2_128", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.normalize_term", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2" ]
[]
false
false
true
false
false
let lemma_proj_g_pow2_192_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX:S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY:S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ:S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.proj_g_pow2_128_lseq
val proj_g_pow2_128_lseq : LSeq.lseq uint64 15
val proj_g_pow2_128_lseq : LSeq.lseq uint64 15
let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 134, "start_col": 0, "start_line": 132 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Lib.Sequence.lseq Lib.IntTypes.uint64 15
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq_of_list", "Lib.IntTypes.uint64", "Hacl.K256.PrecompTable.proj_g_pow2_128_list", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.K256.PrecompTable.point_list", "Hacl.Spec.K256.PrecompTable.proj_point_to_list", "Hacl.K256.PrecompTable.proj_g_pow2_128", "Lib.Sequence.lseq" ]
[]
false
false
false
false
false
let proj_g_pow2_128_lseq:LSeq.lseq uint64 15 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list
false
Steel.ST.HigherArray.fst
Steel.ST.HigherArray.malloc0
val malloc0 (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ base_len (base (ptr_of a)) == US.v n)
val malloc0 (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ base_len (base (ptr_of a)) == US.v n)
let malloc0 (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ base_len (base (ptr_of a)) == US.v n ) = let c : carrier elt (US.v n) = mk_carrier (US.v n) 0 (Seq.create (US.v n) x) P.full_perm in let base : ref (carrier elt (US.v n)) (pcm elt (US.v n)) = R.alloc c in R.pts_to_not_null base _; let p = { base_len = n; base = base; offset = 0; } in let a = (| p, Ghost.hide (US.v n) |) in change_r_pts_to base c (ptr_of a).base c; intro_pts_to a P.full_perm (Seq.create (US.v n) x); return a
{ "file_name": "lib/steel/Steel.ST.HigherArray.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 10, "end_line": 287, "start_col": 0, "start_line": 260 }
(* Copyright 2022 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 Steel.ST.HigherArray module P = Steel.PCMFrac module R = Steel.ST.PCMReference module M = FStar.Map module PM = Steel.PCMMap [@@noextract_to "krml"] let index_t (len: Ghost.erased nat) : Tot Type0 = (i: nat { i < len }) [@@noextract_to "krml"] let carrier (elt: Type u#a) (len: Ghost.erased nat) : Tot Type = PM.map (index_t len) (P.fractional elt) [@@noextract_to "krml"] let pcm (elt: Type u#a) (len: Ghost.erased nat) : Tot (P.pcm (carrier elt len)) = PM.pointwise (index_t len) (P.pcm_frac #elt) [@@noextract_to "krml"] let one (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.one let composable (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.composable [@@noextract_to "krml"] let compose (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.op [@@noextract_to "krml"] let mk_carrier (#elt: Type) (len: nat) (offset: nat) (s: Seq.seq elt) (p: P.perm) : Tot (carrier elt len) = let f (i: nat) : Tot (P.fractional elt) = if offset + Seq.length s > len || i < offset || i >= offset + Seq.length s then None else Some (Seq.index s (i - offset), p) in M.map_literal f let mk_carrier_inj (#elt: Type) (len: nat) (offset: nat) (s1 s2: Seq.seq elt) (p1 p2: P.perm) : Lemma (requires ( mk_carrier len offset s1 p1 == mk_carrier len offset s2 p2 /\ offset + Seq.length s1 <= len /\ offset + Seq.length s2 <= len )) (ensures ( s1 `Seq.equal` s2 /\ (Seq.length s1 > 0 ==> p1 == p2) )) = assert (forall (i: nat) . i < Seq.length s1 ==> (M.sel (mk_carrier len offset s1 p1) (offset + i) == Some (Seq.index s1 i, p1))); assert (forall (i: nat) . i < Seq.length s2 ==> M.sel (mk_carrier len offset s2 p2) (offset + i) == Some (Seq.index s2 i, p2)) [@@erasable] let base_t (elt: Type u#a) : Tot Type0 = Ghost.erased (base_len: US.t & ref _ (pcm elt (US.v base_len))) let base_len (#elt: Type) (b: base_t elt) : GTot nat = US.v (dfst b) [@@noextract_to "krml"] noeq type ptr (elt: Type u#a) : Type0 = { base_len: Ghost.erased US.t; // U32.t to prove that A.read, A.write offset computation does not overflow. TODO: replace U32.t with size_t base: (r: ref _ (pcm elt (US.v base_len)) { core_ref_is_null r ==> US.v base_len == 0 }); offset: (offset: nat { offset <= US.v base_len }); } let null_ptr a = { base_len = 0sz; base = null #_ #(pcm a 0) ; offset = 0 } let is_null_ptr p = is_null p.base let base (#elt: Type) (p: ptr elt) : Tot (base_t elt) = (| Ghost.reveal p.base_len, p.base |) let offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) = p.offset let ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) = () let base_len_null_ptr _ = () let length_fits #elt a = () let valid_perm (len: nat) (offset: nat) (slice_len: nat) (p: P.perm) : Tot prop = let open FStar.Real in ((offset + slice_len <= len /\ slice_len > 0) ==> (p.P.v <=. one)) [@__reduce__] let pts_to0 (#elt: Type u#1) (a: array elt) (p: P.perm) (s: Seq.seq elt) : Tot vprop = R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p) `star` pure ( valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\ Seq.length s == length a ) let pts_to (#elt: Type u#1) (a: array elt) ([@@@ smt_fallback ] p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop = pts_to0 a p s // this lemma is necessary because Steel.PCMReference is marked unfold let change_r_pts_to (#opened: _) (#carrier: Type u#1) (#pcm: P.pcm carrier) (p: ref carrier pcm) (v: carrier) (#carrier': Type u#1) (#pcm': P.pcm carrier') (p': ref carrier' pcm') (v': carrier') : STGhost unit opened (R.pts_to p v) (fun _ -> R.pts_to p' v') (// keep on distinct lines for error messages carrier == carrier' /\ pcm == pcm' /\ p == p' /\ v == v') (fun _ -> True) = rewrite (R.pts_to p v) (R.pts_to p' v') let intro_pts_to (#opened: _) (#elt: Type u#1) (a: array elt) (#v: _) (p: P.perm) (s: Seq.seq elt) : STGhost unit opened (R.pts_to (ptr_of a).base v) (fun _ -> pts_to a p s) ( v == mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p /\ valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\ Seq.length s == length a ) (fun _ -> True) = change_r_pts_to (ptr_of a).base v (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p); intro_pure _; rewrite (pts_to0 a p s) (pts_to a p s) let elim_pts_to (#opened: _) (#elt: Type u#1) (a: array elt) (p: P.perm) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p)) (True) (fun _ -> valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\ Seq.length s == length a ) = rewrite (pts_to a p s) (pts_to0 a p s); elim_pure _ let pts_to_length a s = elim_pts_to a _ s; intro_pts_to a _ s let pts_to_not_null a s = elim_pts_to a _ s; R.pts_to_not_null _ _; intro_pts_to a _ s let mk_carrier_joinable (#elt: Type) (len: nat) (offset: nat) (s1: Seq.seq elt) (p1: P.perm) (s2: Seq.seq elt) (p2: P.perm) : Lemma (requires ( offset + Seq.length s1 <= len /\ Seq.length s1 == Seq.length s2 /\ P.joinable (pcm elt len) (mk_carrier len offset s1 p1) (mk_carrier len offset s2 p2) )) (ensures ( s1 `Seq.equal` s2 )) = let lem (i: nat { 0 <= i /\ i < Seq.length s1 }) : Lemma (Seq.index s1 i == Seq.index s2 i) [SMTPat (Seq.index s1 i); SMTPat (Seq.index s2 i)] = assert ( forall z . ( P.compatible (pcm elt len) (mk_carrier len offset s1 p1) z /\ P.compatible (pcm elt len) (mk_carrier len offset s2 p2) z ) ==> begin match M.sel z (offset + i) with | None -> False | Some (v, _) -> v == Seq.index s1 i /\ v == Seq.index s2 i end ) in () let pure_star_interp' (p:slprop u#a) (q:prop) (m:mem) : Lemma (interp (p `Steel.Memory.star` Steel.Memory.pure q) m <==> interp p m /\ q) = pure_star_interp p q m; emp_unit p let pts_to_inj a p1 s1 p2 s2 m = Classical.forall_intro reveal_pure; pure_star_interp' (hp_of (R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1))) ( valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s1) p1 /\ Seq.length s1 == length a ) m; pure_star_interp' (hp_of (R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s2 p2))) ( valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s2) p2 /\ Seq.length s2 == length a ) m; pts_to_join (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1) (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s2 p2) m; mk_carrier_joinable (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1 s2 p2
{ "checked_file": "/", "dependencies": [ "Steel.ST.PCMReference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.PCMMap.fst.checked", "Steel.PCMFrac.fst.checked", "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Real.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.HigherArray.fst" }
[ { "abbrev": true, "full_module": "Steel.PCMMap", "short_module": "PM" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.ST.PCMReference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.PCMFrac", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": 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: elt -> n: FStar.SizeT.t -> Steel.ST.Effect.ST (Steel.ST.HigherArray.array elt)
Steel.ST.Effect.ST
[]
[]
[ "FStar.SizeT.t", "Steel.ST.Util.return", "Steel.ST.HigherArray.array", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.HigherArray.pts_to", "Steel.FractionalPermission.full_perm", "FStar.Seq.Base.create", "FStar.SizeT.v", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.ST.HigherArray.intro_pts_to", "Steel.ST.HigherArray.change_r_pts_to", "Steel.ST.HigherArray.carrier", "Prims.nat", "Steel.ST.HigherArray.pcm", "FStar.Ghost.reveal", "Steel.ST.HigherArray.__proj__Mkptr__item__base_len", "Steel.ST.HigherArray.ptr_of", "Steel.ST.HigherArray.__proj__Mkptr__item__base", "Prims.dtuple2", "Steel.ST.HigherArray.ptr", "FStar.Ghost.erased", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.HigherArray.offset", "Steel.ST.HigherArray.base_len", "Steel.ST.HigherArray.base", "Prims.Mkdtuple2", "Steel.ST.HigherArray.Mkptr", "Steel.ST.PCMReference.pts_to_not_null", "Steel.Memory.ref", "Steel.ST.PCMReference.alloc", "Steel.ST.HigherArray.mk_carrier", "Steel.Effect.Common.emp", "Prims.l_True", "Prims.l_and", "Prims.eq2", "Steel.ST.HigherArray.length" ]
[]
false
true
false
false
false
let malloc0 (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ base_len (base (ptr_of a)) == US.v n) =
let c:carrier elt (US.v n) = mk_carrier (US.v n) 0 (Seq.create (US.v n) x) P.full_perm in let base:ref (carrier elt (US.v n)) (pcm elt (US.v n)) = R.alloc c in R.pts_to_not_null base _; let p = { base_len = n; base = base; offset = 0 } in let a = (| p, Ghost.hide (US.v n) |) in change_r_pts_to base c (ptr_of a).base c; intro_pts_to a P.full_perm (Seq.create (US.v n) x); return a
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.mk_proj_g_pow2_64
val mk_proj_g_pow2_64: unit -> StackInline (lbuffer uint64 15ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_64_lseq)
val mk_proj_g_pow2_64: unit -> StackInline (lbuffer uint64 15ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_64_lseq)
let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 187, "start_col": 0, "start_line": 186 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.HyperStack.ST.StackInline (Lib.Buffer.lbuffer Lib.IntTypes.uint64 15ul)
FStar.HyperStack.ST.StackInline
[]
[]
[ "Prims.unit", "Lib.Buffer.createL", "Lib.IntTypes.uint64", "Hacl.K256.PrecompTable.proj_g_pow2_64_list", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let mk_proj_g_pow2_64 () =
createL proj_g_pow2_64_list
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.mk_proj_g_pow2_192
val mk_proj_g_pow2_192: unit -> StackInline (lbuffer uint64 15ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_192_lseq)
val mk_proj_g_pow2_192: unit -> StackInline (lbuffer uint64 15ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_192_lseq)
let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 193, "start_col": 0, "start_line": 192 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.HyperStack.ST.StackInline (Lib.Buffer.lbuffer Lib.IntTypes.uint64 15ul)
FStar.HyperStack.ST.StackInline
[]
[]
[ "Prims.unit", "Lib.Buffer.createL", "Lib.IntTypes.uint64", "Hacl.K256.PrecompTable.proj_g_pow2_192_list", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let mk_proj_g_pow2_192 () =
createL proj_g_pow2_192_list
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_basepoint_table_list_w4
val precomp_basepoint_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 240}
val precomp_basepoint_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 240}
let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 201, "start_col": 0, "start_line": 200 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G]
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 240}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.K256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.K256.PrecompTable.mk_k256_precomp_base_table", "Spec.K256.PointOps.g" ]
[]
false
false
false
false
false
let precomp_basepoint_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 240} =
normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.mk_proj_g_pow2_128
val mk_proj_g_pow2_128: unit -> StackInline (lbuffer uint64 15ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_128_lseq)
val mk_proj_g_pow2_128: unit -> StackInline (lbuffer uint64 15ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_128_lseq)
let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 190, "start_col": 0, "start_line": 189 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.HyperStack.ST.StackInline (Lib.Buffer.lbuffer Lib.IntTypes.uint64 15ul)
FStar.HyperStack.ST.StackInline
[]
[]
[ "Prims.unit", "Lib.Buffer.createL", "Lib.IntTypes.uint64", "Hacl.K256.PrecompTable.proj_g_pow2_128_list", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let mk_proj_g_pow2_128 () =
createL proj_g_pow2_128_list
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_basepoint_table_lemma_w4
val precomp_basepoint_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_aff 16 precomp_basepoint_table_lseq_w4 i)
val precomp_basepoint_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_aff 16 precomp_basepoint_table_lseq_w4 i)
let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 96, "end_line": 209, "start_col": 0, "start_line": 207 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.K256.PrecompTable.precomp_table_acc_inv Hacl.K256.PrecompTable.g_aff 16 Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w4 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.K256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.K256.PrecompTable.mk_k256_precomp_base_table", "Spec.K256.PointOps.g", "Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
true
false
true
false
false
let precomp_basepoint_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w4
val precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240
val precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240
let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 205, "start_col": 0, "start_line": 203 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Lib.Sequence.lseq Lib.IntTypes.uint64 240
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.K256.PrecompTable.precomp_basepoint_table_list_w4", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.K256.PointOps.proj_point", "Hacl.K256.PrecompTable.mk_k256_precomp_base_table", "Spec.K256.PointOps.g", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
false
false
false
false
false
let precomp_basepoint_table_lseq_w4:LSeq.lseq uint64 240 =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_g_pow2_64_table_list_w4
val precomp_g_pow2_64_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 240}
val precomp_g_pow2_64_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 240}
let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15)
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 91, "end_line": 220, "start_col": 0, "start_line": 219 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)]
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "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.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 240}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.K256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.K256.PrecompTable.mk_k256_precomp_base_table", "Hacl.K256.PrecompTable.proj_g_pow2_64" ]
[]
false
false
false
false
false
let precomp_g_pow2_64_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 240} =
normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lemma_w4
val precomp_g_pow2_64_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4 i)
val precomp_g_pow2_64_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4 i)
let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma ()
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 230, "start_col": 0, "start_line": 226 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.K256.PrecompTable.precomp_table_acc_inv Hacl.K256.PrecompTable.g_pow2_64 16 Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lseq_w4 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.K256.PrecompTable.proj_g_pow2_64_lemma", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.K256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.K256.PrecompTable.mk_k256_precomp_base_table", "Hacl.K256.PrecompTable.proj_g_pow2_64", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
true
false
true
false
false
let precomp_g_pow2_64_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma ()
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lseq_w4
val precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 240
val precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 240
let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 224, "start_col": 0, "start_line": 222 }
module Hacl.K256.PrecompTable 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 SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "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.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.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
Lib.Sequence.lseq Lib.IntTypes.uint64 240
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_list_w4", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.K256.PointOps.proj_point", "Hacl.K256.PrecompTable.mk_k256_precomp_base_table", "Hacl.K256.PrecompTable.proj_g_pow2_64", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
false
false
false
false
false
let precomp_g_pow2_64_table_lseq_w4:LSeq.lseq uint64 240 =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u8_from_UInt8
val u8_from_UInt8: (n:FStar.UInt8.t) -> u:uint8{uint_v #U8 u = UInt8.v n}
val u8_from_UInt8: (n:FStar.UInt8.t) -> u:uint8{uint_v #U8 u = UInt8.v n}
let u8_from_UInt8 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 12, "start_col": 0, "start_line": 12 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: FStar.UInt8.t -> u4: Lib.IntTypes.uint8{Lib.IntTypes.uint_v u4 = FStar.UInt8.v n}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t", "Lib.IntTypes.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U8", "FStar.UInt.size", "FStar.UInt8.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_from_UInt8 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u16_from_UInt16
val u16_from_UInt16: (n:FStar.UInt16.t) -> u:uint16{uint_v #U16 u = UInt16.v n}
val u16_from_UInt16: (n:FStar.UInt16.t) -> u:uint16{uint_v #U16 u = UInt16.v n}
let u16_from_UInt16 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 14, "start_col": 0, "start_line": 14 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: FStar.UInt16.t -> u7: Lib.IntTypes.uint16{Lib.IntTypes.uint_v u7 = FStar.UInt16.v n}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t", "Lib.IntTypes.uint16", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U16", "FStar.UInt.size", "FStar.UInt16.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_from_UInt16 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u32_from_UInt32
val u32_from_UInt32: (n:FStar.UInt32.t) -> u:uint32{uint_v #U32 u = UInt32.v n}
val u32_from_UInt32: (n:FStar.UInt32.t) -> u:uint32{uint_v #U32 u = UInt32.v n}
let u32_from_UInt32 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 16, "start_col": 0, "start_line": 16 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: FStar.UInt32.t -> u10: Lib.IntTypes.uint32{Lib.IntTypes.uint_v u10 = FStar.UInt32.v n}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Lib.IntTypes.uint32", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "FStar.UInt.size", "FStar.UInt32.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let u32_from_UInt32 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u64_from_UInt64
val u64_from_UInt64: (n:FStar.UInt64.t) -> u:uint64{uint_v #U64 u = UInt64.v n}
val u64_from_UInt64: (n:FStar.UInt64.t) -> u:uint64{uint_v #U64 u = UInt64.v n}
let u64_from_UInt64 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 18, "start_col": 0, "start_line": 18 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: FStar.UInt64.t -> u13: Lib.IntTypes.uint64{Lib.IntTypes.uint_v u13 = FStar.UInt64.v n}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "Lib.IntTypes.uint64", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U64", "FStar.UInt.size", "FStar.UInt64.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_from_UInt64 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u128_from_UInt128
val u128_from_UInt128: (n:FStar.UInt128.t) -> u:uint128{uint_v #U128 u = UInt128.v n}
val u128_from_UInt128: (n:FStar.UInt128.t) -> u:uint128{uint_v #U128 u = UInt128.v n}
let u128_from_UInt128 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 20, "start_col": 0, "start_line": 20 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: FStar.UInt128.t -> u16: Lib.IntTypes.uint128{Lib.IntTypes.uint_v u16 = FStar.UInt128.v n}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt128.t", "Lib.IntTypes.uint128", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U128", "FStar.UInt.size", "FStar.UInt128.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt128.v" ]
[]
false
false
false
false
false
let u128_from_UInt128 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u8_to_UInt8
val u8_to_UInt8: (u:uint8) -> n:UInt8.t{uint_v #U8 u = UInt8.v n}
val u8_to_UInt8: (u:uint8) -> n:UInt8.t{uint_v #U8 u = UInt8.v n}
let u8_to_UInt8 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 24, "start_col": 0, "start_line": 24 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x let size_from_UInt32 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u21: Lib.IntTypes.uint8 -> n: FStar.UInt8.t{Lib.IntTypes.uint_v u21 = FStar.UInt8.v n}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint8", "FStar.UInt8.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U8", "FStar.UInt.size", "FStar.UInt8.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_to_UInt8 x =
x
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.reveal
val reveal (r:rid) :GTot (list (int * int))
val reveal (r:rid) :GTot (list (int * int))
let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r)
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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 -> Prims.GTot (Prims.list (Prims.int * Prims.int))
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.tuple3", "Prims.int", "Prims.bool", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Ghost.reveal", "Prims.list" ]
[]
false
false
false
false
false
let reveal r =
FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r)
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u16_to_UInt16
val u16_to_UInt16: (u:uint16) -> n:UInt16.t{uint_v #U16 u = UInt16.v n}
val u16_to_UInt16: (u:uint16) -> n:UInt16.t{uint_v #U16 u = UInt16.v n}
let u16_to_UInt16 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 26, "start_col": 0, "start_line": 26 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x let size_from_UInt32 x = x let u8_to_UInt8 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u24: Lib.IntTypes.uint16 -> n: FStar.UInt16.t{Lib.IntTypes.uint_v u24 = FStar.UInt16.v n}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint16", "FStar.UInt16.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U16", "FStar.UInt.size", "FStar.UInt16.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_to_UInt16 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.size_from_UInt32
val size_from_UInt32: (n:FStar.UInt32.t) -> u:size_t{uint_v u = UInt32.v n}
val size_from_UInt32: (n:FStar.UInt32.t) -> u:size_t{uint_v u = UInt32.v n}
let size_from_UInt32 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 22, "start_col": 0, "start_line": 22 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: FStar.UInt32.t -> u19: Lib.IntTypes.size_t{Lib.IntTypes.uint_v u19 = FStar.UInt32.v n}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "FStar.UInt.size", "FStar.UInt32.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.PUB", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let size_from_UInt32 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.size_to_UInt32
val size_to_UInt32: (u:size_t) -> n:UInt32.t{uint_v u = UInt32.v n}
val size_to_UInt32: (u:size_t) -> n:UInt32.t{uint_v u = UInt32.v n}
let size_to_UInt32 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 34, "start_col": 0, "start_line": 34 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x let size_from_UInt32 x = x let u8_to_UInt8 x = x let u16_to_UInt16 x = x let u32_to_UInt32 x = x let u64_to_UInt64 x = x let u128_to_UInt128 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u36: Lib.IntTypes.size_t -> n: FStar.UInt32.t{Lib.IntTypes.uint_v u36 = FStar.UInt32.v n}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "FStar.UInt.size", "FStar.UInt32.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.PUB", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let size_to_UInt32 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u32_to_UInt32
val u32_to_UInt32: (u:uint32) -> n:UInt32.t{uint_v #U32 u = UInt32.v n}
val u32_to_UInt32: (u:uint32) -> n:UInt32.t{uint_v #U32 u = UInt32.v n}
let u32_to_UInt32 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 28, "start_col": 0, "start_line": 28 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x let size_from_UInt32 x = x let u8_to_UInt8 x = x let u16_to_UInt16 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u27: Lib.IntTypes.uint32 -> n: FStar.UInt32.t{Lib.IntTypes.uint_v u27 = FStar.UInt32.v n}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint32", "FStar.UInt32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "FStar.UInt.size", "FStar.UInt32.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let u32_to_UInt32 x =
x
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u128_to_UInt128
val u128_to_UInt128: (u:uint128) -> n:UInt128.t{uint_v #U128 u = UInt128.v n}
val u128_to_UInt128: (u:uint128) -> n:UInt128.t{uint_v #U128 u = UInt128.v n}
let u128_to_UInt128 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 32, "start_col": 0, "start_line": 32 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x let size_from_UInt32 x = x let u8_to_UInt8 x = x let u16_to_UInt16 x = x let u32_to_UInt32 x = x let u64_to_UInt64 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u33: Lib.IntTypes.uint128 -> n: FStar.UInt128.t{Lib.IntTypes.uint_v u33 = FStar.UInt128.v n}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint128", "FStar.UInt128.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U128", "FStar.UInt.size", "FStar.UInt128.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt128.v" ]
[]
false
false
false
false
false
let u128_to_UInt128 x =
x
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.rid_length
val rid_length (r:rid) :GTot nat
val rid_length (r:rid) :GTot nat
let rid_length r = List.Tot.length (reveal r)
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 51, "start_col": 0, "start_line": 51 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool)) let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r) let color r = match reveal r with | [] -> 0 | (c, _)::_ -> c let rid_freeable r = match Ghost.reveal r with | [] -> false | (_, _, b)::_ -> b let root = hide [] let root_last_component () = () let lemma_root_has_color_zero _ = () let root_is_not_freeable () = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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 -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.List.Tot.Base.length", "FStar.Pervasives.Native.tuple2", "Prims.int", "FStar.Monotonic.HyperHeap.reveal", "Prims.nat" ]
[]
false
false
false
false
false
let rid_length r =
List.Tot.length (reveal r)
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.rid
val rid :eqtype
val rid :eqtype
let rid = erased (list (int * int * bool))
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 29, "start_col": 0, "start_line": 29 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Prims.list", "FStar.Pervasives.Native.tuple3", "Prims.int", "Prims.bool" ]
[]
false
false
false
true
false
let rid =
erased (list ((int * int) * bool))
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.u64_to_UInt64
val u64_to_UInt64: (u:uint64) -> n:UInt64.t{uint_v #U64 u = UInt64.v n}
val u64_to_UInt64: (u:uint64) -> n:UInt64.t{uint_v #U64 u = UInt64.v n}
let u64_to_UInt64 x = x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 30, "start_col": 0, "start_line": 30 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x let size_from_UInt32 x = x let u8_to_UInt8 x = x let u16_to_UInt16 x = x let u32_to_UInt32 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u30: Lib.IntTypes.uint64 -> n: FStar.UInt64.t{Lib.IntTypes.uint_v u30 = FStar.UInt64.v n}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint64", "FStar.UInt64.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U64", "FStar.UInt.size", "FStar.UInt64.n", "Lib.IntTypes.uint_v", "Lib.IntTypes.SEC", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_to_UInt64 x =
x
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.rid_freeable
val rid_freeable (x:rid) : GTot bool
val rid_freeable (x:rid) : GTot bool
let rid_freeable r = match Ghost.reveal r with | [] -> false | (_, _, b)::_ -> b
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 41, "start_col": 0, "start_line": 38 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool)) let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r) let color r = match reveal r with | [] -> 0 | (c, _)::_ -> c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Ghost.reveal", "Prims.list", "FStar.Pervasives.Native.tuple3", "Prims.int", "Prims.bool" ]
[]
false
false
false
false
false
let rid_freeable r =
match Ghost.reveal r with | [] -> false | (_, _, b) :: _ -> b
false
Lib.RawIntTypes.fst
Lib.RawIntTypes.uint_to_nat
val uint_to_nat: #t:inttype{unsigned t} -> #l:secrecy_level -> u:uint_t t l -> n:nat{n = uint_v #t u}
val uint_to_nat: #t:inttype{unsigned t} -> #l:secrecy_level -> u:uint_t t l -> n:nat{n = uint_v #t u}
let uint_to_nat #t #l (x:uint_t t l) = uint_v #t #l x
{ "file_name": "lib/Lib.RawIntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 53, "end_line": 36, "start_col": 0, "start_line": 36 }
module Lib.RawIntTypes open Lib.IntTypes (* This module offers direct access to the internals of IntTypes. Typechecking it requires full access to IntTypes.fst (not just IntTypes.fsti) Use only if you need to, because using this module will load more F* dependencies. More importantly, using the u*_to_UInt* functions BREAKS secret independence. *) friend Lib.IntTypes let u8_from_UInt8 x = x let u16_from_UInt16 x = x let u32_from_UInt32 x = x let u64_from_UInt64 x = x let u128_from_UInt128 x = x let size_from_UInt32 x = x let u8_to_UInt8 x = x let u16_to_UInt16 x = x let u32_to_UInt32 x = x let u64_to_UInt64 x = x let u128_to_UInt128 x = x let size_to_UInt32 x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Lib.RawIntTypes.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u47: Lib.IntTypes.uint_t t l -> n: Prims.nat{n = Lib.IntTypes.uint_v u47}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.inttype", "Prims.b2t", "Lib.IntTypes.unsigned", "Lib.IntTypes.secrecy_level", "Lib.IntTypes.uint_t", "Lib.IntTypes.uint_v", "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range" ]
[]
false
false
false
false
false
let uint_to_nat #t #l (x: uint_t t l) =
uint_v #t #l x
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.color
val color (x:rid) :GTot int
val color (x:rid) :GTot int
let color r = match reveal r with | [] -> 0 | (c, _)::_ -> c
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 36, "start_col": 0, "start_line": 33 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool)) let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.int
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperHeap.reveal", "Prims.int", "Prims.list", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
false
false
let color r =
match reveal r with | [] -> 0 | (c, _) :: _ -> c
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.rid_tail
val rid_tail (r:rid{rid_length r > 0}) :rid
val rid_tail (r:rid{rid_length r > 0}) :rid
let rid_tail (r:rid{rid_length r > 0}) = elift1_p (tot_to_gtot Cons?.tl) r
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 74, "end_line": 53, "start_col": 0, "start_line": 53 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool)) let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r) let color r = match reveal r with | [] -> 0 | (c, _)::_ -> c let rid_freeable r = match Ghost.reveal r with | [] -> false | (_, _, b)::_ -> b let root = hide [] let root_last_component () = () let lemma_root_has_color_zero _ = () let root_is_not_freeable () = () let rid_length r = List.Tot.length (reveal r)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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{FStar.Monotonic.HyperHeap.rid_length r > 0} -> FStar.Monotonic.HyperHeap.rid
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "Prims.b2t", "Prims.op_GreaterThan", "FStar.Monotonic.HyperHeap.rid_length", "FStar.Ghost.elift1_p", "Prims.list", "FStar.Pervasives.Native.tuple3", "Prims.int", "Prims.bool", "Prims.uu___is_Cons", "FStar.Ghost.tot_to_gtot", "Prims.__proj__Cons__item__tl" ]
[]
false
false
false
false
false
let rid_tail (r: rid{rid_length r > 0}) =
elift1_p (tot_to_gtot Cons?.tl) r
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.root
val root : r:rid{color r == 0 /\ not (rid_freeable r)}
val root : r:rid{color r == 0 /\ not (rid_freeable r)}
let root = hide []
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 43, "start_col": 0, "start_line": 43 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool)) let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r) let color r = match reveal r with | [] -> 0 | (c, _)::_ -> c let rid_freeable r = match Ghost.reveal r with | [] -> false | (_, _, b)::_ -> b
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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 { FStar.Monotonic.HyperHeap.color r == 0 /\ Prims.op_Negation (FStar.Monotonic.HyperHeap.rid_freeable r) }
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.hide", "Prims.list", "FStar.Pervasives.Native.tuple3", "Prims.int", "Prims.bool", "Prims.Nil" ]
[]
false
false
false
false
false
let root =
hide []
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.includes
val includes (r1:rid) (r2:rid) :GTot bool (decreases (reveal r2))
val includes (r1:rid) (r2:rid) :GTot bool (decreases (reveal r2))
let rec includes r1 r2 = if r1 = r2 then true else if rid_length r2 > rid_length r1 then includes r1 (rid_tail r2) else false
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 59, "start_col": 0, "start_line": 55 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool)) let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r) let color r = match reveal r with | [] -> 0 | (c, _)::_ -> c let rid_freeable r = match Ghost.reveal r with | [] -> false | (_, _, b)::_ -> b let root = hide [] let root_last_component () = () let lemma_root_has_color_zero _ = () let root_is_not_freeable () = () let rid_length r = List.Tot.length (reveal r) let rid_tail (r:rid{rid_length r > 0}) = elift1_p (tot_to_gtot Cons?.tl) r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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
r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool
Prims.GTot
[ "sometrivial", "" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "Prims.op_Equality", "Prims.bool", "Prims.op_GreaterThan", "FStar.Monotonic.HyperHeap.rid_length", "FStar.Monotonic.HyperHeap.includes", "FStar.Monotonic.HyperHeap.rid_tail" ]
[ "recursion" ]
false
false
false
false
false
let rec includes r1 r2 =
if r1 = r2 then true else if rid_length r2 > rid_length r1 then includes r1 (rid_tail r2) else false
false
FStar.Monotonic.HyperHeap.fst
FStar.Monotonic.HyperHeap.lemma_aux
val lemma_aux (k i: rid) : Lemma (requires (rid_length k > 0 /\ rid_length k <= rid_length i /\ includes k i /\ not (includes (rid_tail k) i))) (ensures False) (decreases (rid_length i))
val lemma_aux (k i: rid) : Lemma (requires (rid_length k > 0 /\ rid_length k <= rid_length i /\ includes k i /\ not (includes (rid_tail k) i))) (ensures False) (decreases (rid_length i))
let rec lemma_aux (k:rid) (i:rid) :Lemma (requires (rid_length k > 0 /\ rid_length k <= rid_length i /\ includes k i /\ not (includes (rid_tail k) i))) (ensures False) (decreases (rid_length i)) = lemma_aux k (rid_tail i)
{ "file_name": "ulib/FStar.Monotonic.HyperHeap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 68, "start_col": 8, "start_line": 61 }
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and 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.Monotonic.HyperHeap module Set = FStar.Set module Map = FStar.Map open FStar.Monotonic.Heap open FStar.Ghost (* * This is a temporary assumption, we should fix the model to get rid of it *) assume HasEq_rid: hasEq (erased (list (int * int * bool))) let rid = erased (list (int * int * bool)) let reveal r = FStar.List.Tot.map (fun (i, j, _) -> i, j) (reveal r) let color r = match reveal r with | [] -> 0 | (c, _)::_ -> c let rid_freeable r = match Ghost.reveal r with | [] -> false | (_, _, b)::_ -> b let root = hide [] let root_last_component () = () let lemma_root_has_color_zero _ = () let root_is_not_freeable () = () let rid_length r = List.Tot.length (reveal r) let rid_tail (r:rid{rid_length r > 0}) = elift1_p (tot_to_gtot Cons?.tl) r let rec includes r1 r2 = if r1 = r2 then true else if rid_length r2 > rid_length r1 then includes r1 (rid_tail r2) else false
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Heap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.Monotonic.HyperHeap.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic.Heap", "short_module": null }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "Map" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": 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
k: FStar.Monotonic.HyperHeap.rid -> i: FStar.Monotonic.HyperHeap.rid -> FStar.Pervasives.Lemma (requires FStar.Monotonic.HyperHeap.rid_length k > 0 /\ FStar.Monotonic.HyperHeap.rid_length k <= FStar.Monotonic.HyperHeap.rid_length i /\ FStar.Monotonic.HyperHeap.includes k i /\ Prims.op_Negation (FStar.Monotonic.HyperHeap.includes (FStar.Monotonic.HyperHeap.rid_tail k) i)) (ensures Prims.l_False) (decreases FStar.Monotonic.HyperHeap.rid_length i)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperHeap.lemma_aux", "FStar.Monotonic.HyperHeap.rid_tail", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "FStar.Monotonic.HyperHeap.rid_length", "Prims.op_LessThanOrEqual", "FStar.Monotonic.HyperHeap.includes", "Prims.op_Negation", "Prims.squash", "Prims.l_False", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_aux (k i: rid) : Lemma (requires (rid_length k > 0 /\ rid_length k <= rid_length i /\ includes k i /\ not (includes (rid_tail k) i))) (ensures False) (decreases (rid_length i)) =
lemma_aux k (rid_tail i)
false