effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1) | let modifies_one id h0 h1 = | false | null | false | modifies_one id (get_hmap h0) (get_hmap h1) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.mem'",
"FStar.Monotonic.HyperHeap.modifies_one",
"FStar.Monotonic.HyperStack.get_hmap",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2)) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_one : id: FStar.Monotonic.HyperHeap.rid ->
h0: FStar.Monotonic.HyperStack.mem' ->
h1: FStar.Monotonic.HyperStack.mem'
-> Prims.logical | [] | FStar.Monotonic.HyperStack.modifies_one | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
id: FStar.Monotonic.HyperHeap.rid ->
h0: FStar.Monotonic.HyperStack.mem' ->
h1: FStar.Monotonic.HyperStack.mem'
-> Prims.logical | {
"end_col": 71,
"end_line": 431,
"start_col": 28,
"start_line": 431
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0))) | let popped (m0 m1: mem) = | false | null | false | poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\ Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0))) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"FStar.Monotonic.HyperStack.poppable",
"FStar.Map.t",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"Prims.l_not",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.root",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Monotonic.HyperHeap.parent",
"FStar.Set.equal",
"FStar.Map.domain",
"FStar.Monotonic.HyperStack.remove_elt",
"FStar.Map.equal",
"FStar.Map.restrict",
"Prims.logical",
"FStar.Pervasives.Native.tuple4",
"FStar.Pervasives.Native.Mktuple4",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x)) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val popped : m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Prims.logical | [] | FStar.Monotonic.HyperStack.popped | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Prims.logical | {
"end_col": 52,
"end_line": 198,
"start_col": 2,
"start_line": 194
} |
|
Prims.Tot | val empty_mem:mem | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip | val empty_mem:mem
let empty_mem:mem = | false | null | false | let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Monotonic.HyperHeap.root_last_component",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Monotonic.HyperHeap.color",
"Prims.b2t",
"Prims.op_Negation",
"FStar.Monotonic.HyperHeap.rid_freeable",
"FStar.Monotonic.HyperHeap.root",
"FStar.Map.t",
"FStar.Monotonic.Heap.heap",
"FStar.Map.upd",
"FStar.Monotonic.Heap.emp",
"FStar.Map.restrict",
"FStar.Set.empty",
"FStar.Map.const"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty_mem:mem | [] | FStar.Monotonic.HyperStack.empty_mem | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Monotonic.HyperStack.mem | {
"end_col": 16,
"end_line": 181,
"start_col": 21,
"start_line": 175
} |
FStar.Pervasives.Lemma | val heap_region_does_not_overlap_with_tip
(m: mem)
(r:
rid
{ is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\
is_stack_region (get_tip m) })
: Lemma (requires True) (ensures (~(r `is_in` (get_hmap m)))) | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero() | val heap_region_does_not_overlap_with_tip
(m: mem)
(r:
rid
{ is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\
is_stack_region (get_tip m) })
: Lemma (requires True) (ensures (~(r `is_in` (get_hmap m))))
let heap_region_does_not_overlap_with_tip
(m: mem)
(r:
rid
{ is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\
is_stack_region (get_tip m) })
: Lemma (requires True) (ensures (~(r `is_in` (get_hmap m)))) = | false | null | true | root_has_color_zero () | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"lemma"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_and",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_heap_color",
"FStar.Monotonic.HyperHeap.color",
"Prims.op_Negation",
"FStar.Monotonic.HyperHeap.disjoint",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.l_not",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.root",
"FStar.Monotonic.HyperStack.is_stack_region",
"FStar.Monotonic.HyperHeap.root_has_color_zero",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"FStar.Monotonic.HyperStack.is_in",
"FStar.Monotonic.HyperStack.get_hmap",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val heap_region_does_not_overlap_with_tip
(m: mem)
(r:
rid
{ is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\
is_stack_region (get_tip m) })
: Lemma (requires True) (ensures (~(r `is_in` (get_hmap m)))) | [] | FStar.Monotonic.HyperStack.heap_region_does_not_overlap_with_tip | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
m: FStar.Monotonic.HyperStack.mem ->
r:
FStar.Monotonic.HyperHeap.rid
{ FStar.Monotonic.HyperStack.is_heap_color (FStar.Monotonic.HyperHeap.color r) /\
Prims.op_Negation (FStar.Monotonic.HyperHeap.disjoint r
(FStar.Monotonic.HyperStack.get_tip m)) /\ ~(r == FStar.Monotonic.HyperHeap.root) /\
FStar.Monotonic.HyperStack.is_stack_region (FStar.Monotonic.HyperStack.get_tip m) }
-> FStar.Pervasives.Lemma
(ensures ~(FStar.Monotonic.HyperStack.is_in r (FStar.Monotonic.HyperStack.get_hmap m))) | {
"end_col": 25,
"end_line": 187,
"start_col": 4,
"start_line": 187
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp | let fresh_frame (m0 m1: mem) = | false | null | false | not ((get_hmap m0) `Map.contains` (get_tip m1)) /\ parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Negation",
"FStar.Map.contains",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.parent",
"FStar.Map.t",
"FStar.Map.upd",
"FStar.Monotonic.Heap.emp",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fresh_frame : m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Prims.logical | [] | FStar.Monotonic.HyperStack.fresh_frame | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Prims.logical | {
"end_col": 60,
"end_line": 345,
"start_col": 2,
"start_line": 343
} |
|
Prims.Tot | val pop (m0: mem{poppable m0}) : mem | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1 | val pop (m0: mem{poppable m0}) : mem
let pop (m0: mem{poppable m0}) : mem = | false | null | false | let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero ();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.poppable",
"FStar.Map.t",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"Prims.l_not",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.root",
"Prims.int",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Monotonic.HyperHeap.parent",
"FStar.Map.restrict",
"FStar.Set.set",
"FStar.Monotonic.HyperStack.remove_elt",
"FStar.Map.domain",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Monotonic.HyperHeap.root_has_color_zero",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_tip",
"FStar.Monotonic.HyperStack.get_rid_ctr"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0))) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pop (m0: mem{poppable m0}) : mem | [] | FStar.Monotonic.HyperStack.pop | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m0: FStar.Monotonic.HyperStack.mem{FStar.Monotonic.HyperStack.poppable m0}
-> FStar.Monotonic.HyperStack.mem | {
"end_col": 25,
"end_line": 208,
"start_col": 36,
"start_line": 200
} |
Prims.GTot | val modifies_some_refs (i rs: some_refs) (h0 h1: mem) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let rec modifies_some_refs (i:some_refs) (rs:some_refs) (h0:mem) (h1:mem) :GTot Type0 =
match i with
| [] -> True
| (Ref x)::tl ->
(modifies_ref (frameOf x) (refs_in_region (frameOf x) rs) h0 h1) /\
(modifies_some_refs tl rs h0 h1) | val modifies_some_refs (i rs: some_refs) (h0 h1: mem) : GTot Type0
let rec modifies_some_refs (i rs: some_refs) (h0 h1: mem) : GTot Type0 = | false | null | false | match i with
| [] -> True
| Ref x :: tl ->
(modifies_ref (frameOf x) (refs_in_region (frameOf x) rs) h0 h1) /\
(modifies_some_refs tl rs h0 h1) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.some_refs",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_True",
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.list",
"FStar.Monotonic.HyperStack.some_ref",
"Prims.l_and",
"FStar.Monotonic.HyperStack.modifies_ref",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.refs_in_region",
"FStar.Monotonic.HyperStack.modifies_some_refs"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2))
let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1)
let modifies_ref (id:rid) (s:Set.set nat) (h0:mem) (h1:mem) =
Heap.modifies s (get_hmap h0 `Map.sel` id) (get_hmap h1 `Map.sel` id)
(****** API for generating modifies clauses in the old style, should use new modifies clauses now ******)
noeq type some_ref =
| Ref: #a:Type0 -> #rel:preorder a -> mreference a rel -> some_ref
let some_refs = list some_ref
[@@"opaque_to_smt"]
private let rec regions_of_some_refs (rs:some_refs) :Tot (Set.set rid) =
match rs with
| [] -> Set.empty
| (Ref r)::tl -> Set.union (Set.singleton (frameOf r)) (regions_of_some_refs tl)
[@@"opaque_to_smt"]
private let rec refs_in_region (r:rid) (rs:some_refs) :GTot (Set.set nat) =
match rs with
| [] -> Set.empty
| (Ref x)::tl ->
Set.union (if frameOf x = r then Set.singleton (as_addr x) else Set.empty)
(refs_in_region r tl)
[@@"opaque_to_smt"] | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_some_refs (i rs: some_refs) (h0 h1: mem) : GTot Type0 | [
"recursion"
] | FStar.Monotonic.HyperStack.modifies_some_refs | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
i: FStar.Monotonic.HyperStack.some_refs ->
rs: FStar.Monotonic.HyperStack.some_refs ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> Prims.GTot Type0 | {
"end_col": 36,
"end_line": 463,
"start_col": 2,
"start_line": 459
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let modifies_ref (id:rid) (s:Set.set nat) (h0:mem) (h1:mem) =
Heap.modifies s (get_hmap h0 `Map.sel` id) (get_hmap h1 `Map.sel` id) | let modifies_ref (id: rid) (s: Set.set nat) (h0 h1: mem) = | false | null | false | Heap.modifies s ((get_hmap h0) `Map.sel` id) ((get_hmap h1) `Map.sel` id) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Set.set",
"Prims.nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.Heap.modifies",
"FStar.Map.sel",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2))
let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_ref : id: FStar.Monotonic.HyperHeap.rid ->
s: FStar.Set.set Prims.nat ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | [] | FStar.Monotonic.HyperStack.modifies_ref | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
id: FStar.Monotonic.HyperHeap.rid ->
s: FStar.Set.set Prims.nat ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | {
"end_col": 71,
"end_line": 433,
"start_col": 2,
"start_line": 433
} |
|
Prims.Tot | val sel_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) : Tot a | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r) | val sel_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) : Tot a
let sel_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) : Tot a = | false | null | false | Heap.sel_tot ((get_hmap m) `Map.sel` (frameOf r)) (as_ref r) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.HyperStack.contains",
"FStar.Monotonic.Heap.sel_tot",
"FStar.Map.sel",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.as_ref"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sel_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) : Tot a | [] | FStar.Monotonic.HyperStack.sel_tot | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
m: FStar.Monotonic.HyperStack.mem ->
r: FStar.Monotonic.HyperStack.mreference a rel {FStar.Monotonic.HyperStack.contains m r}
-> a | {
"end_col": 62,
"end_line": 340,
"start_col": 4,
"start_line": 340
} |
Prims.Tot | val free_heap_region
(m0: mem)
(r: rid{is_heap_color (color r) /\ rid_freeable r /\ (get_hmap m0) `Map.contains` r})
: mem | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0) | val free_heap_region
(m0: mem)
(r: rid{is_heap_color (color r) /\ rid_freeable r /\ (get_hmap m0) `Map.contains` r})
: mem
let free_heap_region
(m0: mem)
(r: rid{is_heap_color (color r) /\ rid_freeable r /\ (get_hmap m0) `Map.contains` r})
: mem = | false | null | false | let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_and",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_heap_color",
"FStar.Monotonic.HyperHeap.color",
"FStar.Monotonic.HyperHeap.rid_freeable",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Map.t",
"Prims.int",
"FStar.Monotonic.HyperStack.mk_mem",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Map.restrict",
"FStar.Set.set",
"FStar.Monotonic.HyperStack.remove_elt",
"FStar.Map.domain",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r}) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val free_heap_region
(m0: mem)
(r: rid{is_heap_color (color r) /\ rid_freeable r /\ (get_hmap m0) `Map.contains` r})
: mem | [] | FStar.Monotonic.HyperStack.free_heap_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
m0: FStar.Monotonic.HyperStack.mem ->
r:
FStar.Monotonic.HyperHeap.rid
{ FStar.Monotonic.HyperStack.is_heap_color (FStar.Monotonic.HyperHeap.color r) /\
FStar.Monotonic.HyperHeap.rid_freeable r /\
FStar.Map.contains (FStar.Monotonic.HyperStack.get_hmap m0) r }
-> FStar.Monotonic.HyperStack.mem | {
"end_col": 41,
"end_line": 392,
"start_col": 1,
"start_line": 387
} |
Prims.GTot | val upd
(#a: Type)
(#rel: preorder a)
(m: mem)
(s: mreference a rel {live_region m (frameOf s)})
(v: a)
: GTot mem | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip | val upd
(#a: Type)
(#rel: preorder a)
(m: mem)
(s: mreference a rel {live_region m (frameOf s)})
(v: a)
: GTot mem
let upd
(#a: Type)
(#rel: preorder a)
(m: mem)
(s: mreference a rel {live_region m (frameOf s)})
(v: a)
: GTot mem = | false | null | false | let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.mreference",
"Prims.b2t",
"FStar.Monotonic.HyperStack.live_region",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Map.t",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"Prims.int",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Map.upd",
"FStar.Monotonic.Heap.upd",
"FStar.Map.sel",
"FStar.Monotonic.HyperStack.as_ref",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val upd
(#a: Type)
(#rel: preorder a)
(m: mem)
(s: mreference a rel {live_region m (frameOf s)})
(v: a)
: GTot mem | [] | FStar.Monotonic.HyperStack.upd | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
m: FStar.Monotonic.HyperStack.mem ->
s:
FStar.Monotonic.HyperStack.mreference a rel
{FStar.Monotonic.HyperStack.live_region m (FStar.Monotonic.HyperStack.frameOf s)} ->
v: a
-> Prims.GTot FStar.Monotonic.HyperStack.mem | {
"end_col": 24,
"end_line": 303,
"start_col": 3,
"start_line": 298
} |
Prims.Tot | val free (#a: Type0) (#rel: preorder a) (r: mreference a rel {is_mm r}) (m: mem{m `contains` r})
: Tot mem | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip | val free (#a: Type0) (#rel: preorder a) (r: mreference a rel {is_mm r}) (m: mem{m `contains` r})
: Tot mem
let free (#a: Type0) (#rel: preorder a) (r: mreference a rel {is_mm r}) (m: mem{m `contains` r})
: Tot mem = | false | null | false | let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_mm",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.contains",
"FStar.Map.t",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"Prims.int",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Map.upd",
"FStar.Monotonic.Heap.free_mm",
"FStar.Monotonic.HyperStack.as_ref",
"FStar.Map.sel",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r}) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val free (#a: Type0) (#rel: preorder a) (r: mreference a rel {is_mm r}) (m: mem{m `contains` r})
: Tot mem | [] | FStar.Monotonic.HyperStack.free | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
r: FStar.Monotonic.HyperStack.mreference a rel {FStar.Monotonic.HyperStack.is_mm r} ->
m: FStar.Monotonic.HyperStack.mem{FStar.Monotonic.HyperStack.contains m r}
-> FStar.Monotonic.HyperStack.mem | {
"end_col": 24,
"end_line": 325,
"start_col": 3,
"start_line": 318
} |
Prims.Tot | val regions_of_some_refs (rs: some_refs) : Tot (Set.set rid) | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let rec regions_of_some_refs (rs:some_refs) :Tot (Set.set rid) =
match rs with
| [] -> Set.empty
| (Ref r)::tl -> Set.union (Set.singleton (frameOf r)) (regions_of_some_refs tl) | val regions_of_some_refs (rs: some_refs) : Tot (Set.set rid)
let rec regions_of_some_refs (rs: some_refs) : Tot (Set.set rid) = | false | null | false | match rs with
| [] -> Set.empty
| Ref r :: tl -> Set.union (Set.singleton (frameOf r)) (regions_of_some_refs tl) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.some_refs",
"FStar.Set.empty",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.list",
"FStar.Monotonic.HyperStack.some_ref",
"FStar.Set.union",
"FStar.Set.singleton",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.regions_of_some_refs",
"FStar.Set.set"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2))
let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1)
let modifies_ref (id:rid) (s:Set.set nat) (h0:mem) (h1:mem) =
Heap.modifies s (get_hmap h0 `Map.sel` id) (get_hmap h1 `Map.sel` id)
(****** API for generating modifies clauses in the old style, should use new modifies clauses now ******)
noeq type some_ref =
| Ref: #a:Type0 -> #rel:preorder a -> mreference a rel -> some_ref
let some_refs = list some_ref
[@@"opaque_to_smt"] | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val regions_of_some_refs (rs: some_refs) : Tot (Set.set rid) | [
"recursion"
] | FStar.Monotonic.HyperStack.regions_of_some_refs | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | rs: FStar.Monotonic.HyperStack.some_refs -> FStar.Set.set FStar.Monotonic.HyperHeap.rid | {
"end_col": 82,
"end_line": 447,
"start_col": 2,
"start_line": 445
} |
Prims.Tot | val alloc
(#a: Type0)
(rel: preorder a)
(id: rid)
(init: a)
(mm: bool)
(m: mem{(get_hmap m) `Map.contains` id})
: Tot
(p:
(mreference a rel * mem)
{ let r, h = Heap.alloc rel ((get_hmap m) `Map.sel` id) init mm in
as_ref (fst p) == r /\ get_hmap (snd p) == Map.upd (get_hmap m) id h }) | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip | val alloc
(#a: Type0)
(rel: preorder a)
(id: rid)
(init: a)
(mm: bool)
(m: mem{(get_hmap m) `Map.contains` id})
: Tot
(p:
(mreference a rel * mem)
{ let r, h = Heap.alloc rel ((get_hmap m) `Map.sel` id) init mm in
as_ref (fst p) == r /\ get_hmap (snd p) == Map.upd (get_hmap m) id h })
let alloc
(#a: Type0)
(rel: preorder a)
(id: rid)
(init: a)
(mm: bool)
(m: mem{(get_hmap m) `Map.contains` id})
: Tot
(p:
(mreference a rel * mem)
{ let r, h = Heap.alloc rel ((get_hmap m) `Map.sel` id) init mm in
as_ref (fst p) == r /\ get_hmap (snd p) == Map.upd (get_hmap m) id h }) = | false | null | false | let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperHeap.rid",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"Prims.b2t",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Map.t",
"Prims.int",
"FStar.Monotonic.Heap.mref",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.HyperStack.mk_mreference",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Map.upd",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Prims.eq2",
"FStar.Monotonic.HyperStack.as_ref",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.snd",
"FStar.Monotonic.Heap.alloc",
"FStar.Map.sel",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\ | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val alloc
(#a: Type0)
(rel: preorder a)
(id: rid)
(init: a)
(mm: bool)
(m: mem{(get_hmap m) `Map.contains` id})
: Tot
(p:
(mreference a rel * mem)
{ let r, h = Heap.alloc rel ((get_hmap m) `Map.sel` id) init mm in
as_ref (fst p) == r /\ get_hmap (snd p) == Map.upd (get_hmap m) id h }) | [] | FStar.Monotonic.HyperStack.alloc | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
rel: FStar.Preorder.preorder a ->
id: FStar.Monotonic.HyperHeap.rid ->
init: a ->
mm: Prims.bool ->
m: FStar.Monotonic.HyperStack.mem{FStar.Map.contains (FStar.Monotonic.HyperStack.get_hmap m) id}
-> p:
(FStar.Monotonic.HyperStack.mreference a rel * FStar.Monotonic.HyperStack.mem)
{ let _ =
FStar.Monotonic.Heap.alloc rel
(FStar.Map.sel (FStar.Monotonic.HyperStack.get_hmap m) id)
init
mm
in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ r h = _ in
FStar.Monotonic.HyperStack.as_ref (FStar.Pervasives.Native.fst p) == r /\
FStar.Monotonic.HyperStack.get_hmap (FStar.Pervasives.Native.snd p) ==
FStar.Map.upd (FStar.Monotonic.HyperStack.get_hmap m) id h)
<:
Type0 } | {
"end_col": 46,
"end_line": 314,
"start_col": 3,
"start_line": 309
} |
Prims.Tot | val new_freeable_heap_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
: t: (rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)} | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip | val new_freeable_heap_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
: t: (rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
let new_freeable_heap_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
: t: (rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)} = | false | null | false | let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_and",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_eternal_region_hs",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Map.t",
"Prims.int",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.op_Addition",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Map.upd",
"FStar.Monotonic.Heap.emp",
"FStar.Monotonic.HyperHeap.extend_monochrome_freeable",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Pervasives.Native.tuple2",
"FStar.Monotonic.HyperStack.fresh_region",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.snd",
"FStar.Monotonic.HyperHeap.rid_freeable",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent}) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val new_freeable_heap_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
: t: (rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)} | [] | FStar.Monotonic.HyperStack.new_freeable_heap_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
m: FStar.Monotonic.HyperStack.mem ->
parent:
FStar.Monotonic.HyperHeap.rid
{ FStar.Monotonic.HyperStack.is_eternal_region_hs parent /\
FStar.Map.contains (FStar.Monotonic.HyperStack.get_hmap m) parent }
-> t:
(FStar.Monotonic.HyperHeap.rid * FStar.Monotonic.HyperStack.mem)
{ FStar.Monotonic.HyperStack.fresh_region (FStar.Pervasives.Native.fst t)
m
(FStar.Pervasives.Native.snd t) /\
FStar.Monotonic.HyperHeap.rid_freeable (FStar.Pervasives.Native.fst t) } | {
"end_col": 37,
"end_line": 378,
"start_col": 1,
"start_line": 373
} |
Prims.Tot | val hs_push_frame (m: mem) : Tot (m': mem{fresh_frame m m'}) | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid | val hs_push_frame (m: mem) : Tot (m': mem{fresh_frame m m'})
let hs_push_frame (m: mem) : Tot (m': mem{fresh_frame m m'}) = | false | null | false | let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s: rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Map.t",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"Prims.int",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.op_Addition",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"Prims._assert",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_and",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_above",
"FStar.Monotonic.HyperStack.is_in",
"Prims.op_Equality",
"FStar.Map.upd",
"FStar.Monotonic.Heap.emp",
"FStar.Monotonic.HyperHeap.extend",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Monotonic.HyperStack.fresh_frame",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hs_push_frame (m: mem) : Tot (m': mem{fresh_frame m m'}) | [] | FStar.Monotonic.HyperStack.hs_push_frame | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperStack.mem
-> m': FStar.Monotonic.HyperStack.mem{FStar.Monotonic.HyperStack.fresh_frame m m'} | {
"end_col": 38,
"end_line": 354,
"start_col": 3,
"start_line": 348
} |
Prims.GTot | val refs_in_region (r: rid) (rs: some_refs) : GTot (Set.set nat) | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let rec refs_in_region (r:rid) (rs:some_refs) :GTot (Set.set nat) =
match rs with
| [] -> Set.empty
| (Ref x)::tl ->
Set.union (if frameOf x = r then Set.singleton (as_addr x) else Set.empty)
(refs_in_region r tl) | val refs_in_region (r: rid) (rs: some_refs) : GTot (Set.set nat)
let rec refs_in_region (r: rid) (rs: some_refs) : GTot (Set.set nat) = | false | null | false | match rs with
| [] -> Set.empty
| Ref x :: tl ->
Set.union (if frameOf x = r then Set.singleton (as_addr x) else Set.empty) (refs_in_region r tl) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.some_refs",
"FStar.Set.empty",
"Prims.nat",
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.list",
"FStar.Monotonic.HyperStack.some_ref",
"FStar.Set.union",
"Prims.op_Equality",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Set.singleton",
"FStar.Monotonic.HyperStack.as_addr",
"Prims.bool",
"FStar.Set.set",
"FStar.Monotonic.HyperStack.refs_in_region"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2))
let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1)
let modifies_ref (id:rid) (s:Set.set nat) (h0:mem) (h1:mem) =
Heap.modifies s (get_hmap h0 `Map.sel` id) (get_hmap h1 `Map.sel` id)
(****** API for generating modifies clauses in the old style, should use new modifies clauses now ******)
noeq type some_ref =
| Ref: #a:Type0 -> #rel:preorder a -> mreference a rel -> some_ref
let some_refs = list some_ref
[@@"opaque_to_smt"]
private let rec regions_of_some_refs (rs:some_refs) :Tot (Set.set rid) =
match rs with
| [] -> Set.empty
| (Ref r)::tl -> Set.union (Set.singleton (frameOf r)) (regions_of_some_refs tl)
[@@"opaque_to_smt"] | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val refs_in_region (r: rid) (rs: some_refs) : GTot (Set.set nat) | [
"recursion"
] | FStar.Monotonic.HyperStack.refs_in_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperHeap.rid -> rs: FStar.Monotonic.HyperStack.some_refs
-> Prims.GTot (FStar.Set.set Prims.nat) | {
"end_col": 35,
"end_line": 455,
"start_col": 2,
"start_line": 451
} |
Prims.Tot | val new_eternal_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
(c: option int {None? c \/ is_heap_color (Some?.v c)})
: Tot (t: (rid * mem){fresh_region (fst t) m (snd t)}) | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip | val new_eternal_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
(c: option int {None? c \/ is_heap_color (Some?.v c)})
: Tot (t: (rid * mem){fresh_region (fst t) m (snd t)})
let new_eternal_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
(c: option int {None? c \/ is_heap_color (Some?.v c)})
: Tot (t: (rid * mem){fresh_region (fst t) m (snd t)}) = | false | null | false | let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_and",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_eternal_region_hs",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Pervasives.Native.option",
"Prims.int",
"Prims.l_or",
"FStar.Pervasives.Native.uu___is_None",
"FStar.Monotonic.HyperStack.is_heap_color",
"FStar.Pervasives.Native.__proj__Some__item__v",
"FStar.Map.t",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.op_Addition",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Map.upd",
"FStar.Monotonic.Heap.emp",
"FStar.Monotonic.HyperHeap.extend_monochrome",
"Prims.bool",
"FStar.Monotonic.HyperHeap.extend",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Pervasives.Native.tuple2",
"FStar.Monotonic.HyperStack.fresh_region",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)}) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val new_eternal_region
(m: mem)
(parent: rid{is_eternal_region_hs parent /\ (get_hmap m) `Map.contains` parent})
(c: option int {None? c \/ is_heap_color (Some?.v c)})
: Tot (t: (rid * mem){fresh_region (fst t) m (snd t)}) | [] | FStar.Monotonic.HyperStack.new_eternal_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
m: FStar.Monotonic.HyperStack.mem ->
parent:
FStar.Monotonic.HyperHeap.rid
{ FStar.Monotonic.HyperStack.is_eternal_region_hs parent /\
FStar.Map.contains (FStar.Monotonic.HyperStack.get_hmap m) parent } ->
c:
FStar.Pervasives.Native.option Prims.int
{None? c \/ FStar.Monotonic.HyperStack.is_heap_color (Some?.v c)}
-> t:
(FStar.Monotonic.HyperHeap.rid * FStar.Monotonic.HyperStack.mem)
{ FStar.Monotonic.HyperStack.fresh_region (FStar.Pervasives.Native.fst t)
m
(FStar.Pervasives.Native.snd t) } | {
"end_col": 39,
"end_line": 367,
"start_col": 3,
"start_line": 359
} |
Prims.Tot | val upd_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) (v: a)
: Tot mem | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"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
}
] | false | let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip | val upd_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) (v: a)
: Tot mem
let upd_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) (v: a)
: Tot mem = | false | null | false | let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.HyperStack.contains",
"FStar.Map.t",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"Prims.int",
"FStar.Monotonic.HyperStack.mk_mem",
"Prims.unit",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_intro",
"FStar.Map.upd",
"FStar.Monotonic.Heap.upd_tot",
"FStar.Monotonic.HyperStack.as_ref",
"FStar.Map.sel",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.lemma_is_wf_ctr_and_tip_elim",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_rid_ctr",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 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.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val upd_tot (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel {m `contains` r}) (v: a)
: Tot mem | [] | FStar.Monotonic.HyperStack.upd_tot | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
m: FStar.Monotonic.HyperStack.mem ->
r: FStar.Monotonic.HyperStack.mreference a rel {FStar.Monotonic.HyperStack.contains m r} ->
v: a
-> FStar.Monotonic.HyperStack.mem | {
"end_col": 24,
"end_line": 336,
"start_col": 3,
"start_line": 329
} |
FStar.HyperStack.ST.Stack | val has_adx_bmi2: Prims.unit
-> Stack bool
(fun _ -> True)
(ensures
(fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let has_adx_bmi2 (): Stack bool
(fun _ -> True)
(ensures (fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled))))
=
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
has_bmi2 && has_adx | val has_adx_bmi2: Prims.unit
-> Stack bool
(fun _ -> True)
(ensures
(fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled))))
let has_adx_bmi2 ()
: Stack bool
(fun _ -> True)
(ensures
(fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) = | true | null | false | let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
has_bmi2 && has_adx | {
"checked_file": "EverCrypt.Curve25519.fst.checked",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Curve25519_64.fsti.checked",
"Hacl.Curve25519_51.fsti.checked",
"FStar.Pervasives.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": true,
"source_file": "EverCrypt.Curve25519.fst"
} | [] | [
"Prims.unit",
"Prims.op_AmpAmp",
"Prims.bool",
"EverCrypt.AutoConfig2.has_adx",
"EverCrypt.AutoConfig2.has_bmi2",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_True",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.l_imp",
"Prims.b2t",
"Vale.X64.CPU_Features_s.adx_enabled",
"Vale.X64.CPU_Features_s.bmi2_enabled"
] | [] | module EverCrypt.Curve25519
module B = LowStar.Buffer
[@ CInline ]
let has_adx_bmi2 (): Stack bool
(fun _ -> True)
(ensures (fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\ | false | false | EverCrypt.Curve25519.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val has_adx_bmi2: Prims.unit
-> Stack bool
(fun _ -> True)
(ensures
(fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) | [] | EverCrypt.Curve25519.has_adx_bmi2 | {
"file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> FStar.HyperStack.ST.Stack Prims.bool | {
"end_col": 21,
"end_line": 14,
"start_col": 1,
"start_line": 11
} |
FStar.HyperStack.ST.Stack | val secret_to_public:
pub:lbuffer uint8 32ul
-> priv:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 ->
live h0 pub /\ live h0 priv /\ disjoint pub priv)
(ensures fun h0 _ h1 -> modifies (loc pub) h0 h1 /\
as_seq h1 pub == Spec.Curve25519.secret_to_public (as_seq h0 priv)) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secret_to_public pub priv =
if EverCrypt.TargetConfig.hacl_can_compile_vale then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx) then
Hacl.Curve25519_64.secret_to_public pub priv
else
Hacl.Curve25519_51.secret_to_public pub priv
else
Hacl.Curve25519_51.secret_to_public pub priv | val secret_to_public:
pub:lbuffer uint8 32ul
-> priv:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 ->
live h0 pub /\ live h0 priv /\ disjoint pub priv)
(ensures fun h0 _ h1 -> modifies (loc pub) h0 h1 /\
as_seq h1 pub == Spec.Curve25519.secret_to_public (as_seq h0 priv))
let secret_to_public pub priv = | true | null | false | if EverCrypt.TargetConfig.hacl_can_compile_vale
then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx)
then Hacl.Curve25519_64.secret_to_public pub priv
else Hacl.Curve25519_51.secret_to_public pub priv
else Hacl.Curve25519_51.secret_to_public pub priv | {
"checked_file": "EverCrypt.Curve25519.fst.checked",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Curve25519_64.fsti.checked",
"Hacl.Curve25519_51.fsti.checked",
"FStar.Pervasives.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": true,
"source_file": "EverCrypt.Curve25519.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"EverCrypt.TargetConfig.hacl_can_compile_vale",
"Prims.op_AmpAmp",
"Hacl.Curve25519_64.secret_to_public",
"Prims.unit",
"Prims.bool",
"Hacl.Curve25519_51.secret_to_public",
"EverCrypt.AutoConfig2.has_adx",
"EverCrypt.AutoConfig2.has_bmi2"
] | [] | module EverCrypt.Curve25519
module B = LowStar.Buffer
[@ CInline ]
let has_adx_bmi2 (): Stack bool
(fun _ -> True)
(ensures (fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled))))
=
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
has_bmi2 && has_adx
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" | false | false | EverCrypt.Curve25519.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secret_to_public:
pub:lbuffer uint8 32ul
-> priv:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 ->
live h0 pub /\ live h0 priv /\ disjoint pub priv)
(ensures fun h0 _ h1 -> modifies (loc pub) h0 h1 /\
as_seq h1 pub == Spec.Curve25519.secret_to_public (as_seq h0 priv)) | [] | EverCrypt.Curve25519.secret_to_public | {
"file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pub: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> priv: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 48,
"end_line": 26,
"start_col": 2,
"start_line": 18
} |
FStar.HyperStack.ST.Stack | val scalarmult:
shared:lbuffer uint8 32ul
-> my_priv:lbuffer uint8 32ul
-> their_pub:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 ->
live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\
disjoint shared my_priv /\ disjoint shared their_pub)
(ensures fun h0 _ h1 -> modifies (loc shared) h0 h1 /\
as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub)) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scalarmult shared my_priv their_pub =
if EverCrypt.TargetConfig.hacl_can_compile_vale then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx) then
Hacl.Curve25519_64.scalarmult shared my_priv their_pub
else
Hacl.Curve25519_51.scalarmult shared my_priv their_pub
else
Hacl.Curve25519_51.scalarmult shared my_priv their_pub | val scalarmult:
shared:lbuffer uint8 32ul
-> my_priv:lbuffer uint8 32ul
-> their_pub:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 ->
live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\
disjoint shared my_priv /\ disjoint shared their_pub)
(ensures fun h0 _ h1 -> modifies (loc shared) h0 h1 /\
as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub))
let scalarmult shared my_priv their_pub = | true | null | false | if EverCrypt.TargetConfig.hacl_can_compile_vale
then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx)
then Hacl.Curve25519_64.scalarmult shared my_priv their_pub
else Hacl.Curve25519_51.scalarmult shared my_priv their_pub
else Hacl.Curve25519_51.scalarmult shared my_priv their_pub | {
"checked_file": "EverCrypt.Curve25519.fst.checked",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Curve25519_64.fsti.checked",
"Hacl.Curve25519_51.fsti.checked",
"FStar.Pervasives.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": true,
"source_file": "EverCrypt.Curve25519.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"EverCrypt.TargetConfig.hacl_can_compile_vale",
"Prims.op_AmpAmp",
"Hacl.Curve25519_64.scalarmult",
"Prims.unit",
"Prims.bool",
"Hacl.Curve25519_51.scalarmult",
"EverCrypt.AutoConfig2.has_adx",
"EverCrypt.AutoConfig2.has_bmi2"
] | [] | module EverCrypt.Curve25519
module B = LowStar.Buffer
[@ CInline ]
let has_adx_bmi2 (): Stack bool
(fun _ -> True)
(ensures (fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled))))
=
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
has_bmi2 && has_adx
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
let secret_to_public pub priv =
if EverCrypt.TargetConfig.hacl_can_compile_vale then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx) then
Hacl.Curve25519_64.secret_to_public pub priv
else
Hacl.Curve25519_51.secret_to_public pub priv
else
Hacl.Curve25519_51.secret_to_public pub priv | false | false | EverCrypt.Curve25519.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val scalarmult:
shared:lbuffer uint8 32ul
-> my_priv:lbuffer uint8 32ul
-> their_pub:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 ->
live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\
disjoint shared my_priv /\ disjoint shared their_pub)
(ensures fun h0 _ h1 -> modifies (loc shared) h0 h1 /\
as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub)) | [] | EverCrypt.Curve25519.scalarmult | {
"file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
shared: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
my_priv: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
their_pub: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 58,
"end_line": 37,
"start_col": 2,
"start_line": 29
} |
FStar.HyperStack.ST.Stack | val ecdh:
shared:lbuffer uint8 32ul
-> my_priv:lbuffer uint8 32ul
-> their_pub:lbuffer uint8 32ul
-> Stack bool
(requires fun h0 ->
live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\
disjoint shared my_priv /\ disjoint shared their_pub)
(ensures fun h0 r h1 -> modifies (loc shared) h0 h1 /\
as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub)
/\ (not r == Lib.ByteSequence.lbytes_eq #32 (as_seq h1 shared) (Lib.Sequence.create 32 (u8 0)))) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ecdh shared my_priv their_pub =
if EverCrypt.TargetConfig.hacl_can_compile_vale then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx) then
Hacl.Curve25519_64.ecdh shared my_priv their_pub
else
Hacl.Curve25519_51.ecdh shared my_priv their_pub
else
Hacl.Curve25519_51.ecdh shared my_priv their_pub | val ecdh:
shared:lbuffer uint8 32ul
-> my_priv:lbuffer uint8 32ul
-> their_pub:lbuffer uint8 32ul
-> Stack bool
(requires fun h0 ->
live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\
disjoint shared my_priv /\ disjoint shared their_pub)
(ensures fun h0 r h1 -> modifies (loc shared) h0 h1 /\
as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub)
/\ (not r == Lib.ByteSequence.lbytes_eq #32 (as_seq h1 shared) (Lib.Sequence.create 32 (u8 0))))
let ecdh shared my_priv their_pub = | true | null | false | if EverCrypt.TargetConfig.hacl_can_compile_vale
then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx)
then Hacl.Curve25519_64.ecdh shared my_priv their_pub
else Hacl.Curve25519_51.ecdh shared my_priv their_pub
else Hacl.Curve25519_51.ecdh shared my_priv their_pub | {
"checked_file": "EverCrypt.Curve25519.fst.checked",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Curve25519_64.fsti.checked",
"Hacl.Curve25519_51.fsti.checked",
"FStar.Pervasives.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": true,
"source_file": "EverCrypt.Curve25519.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"EverCrypt.TargetConfig.hacl_can_compile_vale",
"Prims.op_AmpAmp",
"Hacl.Curve25519_64.ecdh",
"Prims.bool",
"Hacl.Curve25519_51.ecdh",
"EverCrypt.AutoConfig2.has_adx",
"EverCrypt.AutoConfig2.has_bmi2"
] | [] | module EverCrypt.Curve25519
module B = LowStar.Buffer
[@ CInline ]
let has_adx_bmi2 (): Stack bool
(fun _ -> True)
(ensures (fun h0 b h1 ->
B.(modifies B.loc_none h0 h1) /\
(b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled))))
=
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
has_bmi2 && has_adx
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
let secret_to_public pub priv =
if EverCrypt.TargetConfig.hacl_can_compile_vale then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx) then
Hacl.Curve25519_64.secret_to_public pub priv
else
Hacl.Curve25519_51.secret_to_public pub priv
else
Hacl.Curve25519_51.secret_to_public pub priv
let scalarmult shared my_priv their_pub =
if EverCrypt.TargetConfig.hacl_can_compile_vale then
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in
let has_adx = EverCrypt.AutoConfig2.has_adx () in
if (has_bmi2 && has_adx) then
Hacl.Curve25519_64.scalarmult shared my_priv their_pub
else
Hacl.Curve25519_51.scalarmult shared my_priv their_pub
else
Hacl.Curve25519_51.scalarmult shared my_priv their_pub | false | false | EverCrypt.Curve25519.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ecdh:
shared:lbuffer uint8 32ul
-> my_priv:lbuffer uint8 32ul
-> their_pub:lbuffer uint8 32ul
-> Stack bool
(requires fun h0 ->
live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\
disjoint shared my_priv /\ disjoint shared their_pub)
(ensures fun h0 r h1 -> modifies (loc shared) h0 h1 /\
as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub)
/\ (not r == Lib.ByteSequence.lbytes_eq #32 (as_seq h1 shared) (Lib.Sequence.create 32 (u8 0)))) | [] | EverCrypt.Curve25519.ecdh | {
"file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
shared: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
my_priv: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
their_pub: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Prims.bool | {
"end_col": 52,
"end_line": 48,
"start_col": 2,
"start_line": 40
} |
Prims.Tot | val sealBase: sealBase_st cs True | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sealBase = hpke_sealBase_higher #cs True IAEAD.aead_encrypt_cp128 setupBaseS | val sealBase: sealBase_st cs True
let sealBase = | false | null | false | hpke_sealBase_higher #cs True IAEAD.aead_encrypt_cp128 setupBaseS | {
"checked_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_sealBase_higher",
"Hacl.HPKE.Curve51_CP128_SHA512.cs",
"Prims.l_True",
"Hacl.HPKE.Interface.AEAD.aead_encrypt_cp128",
"Hacl.HPKE.Curve51_CP128_SHA512.setupBaseS"
] | [] | module Hacl.HPKE.Curve51_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0"
let setupBaseS = hpke_setupBaseS_higher #cs True IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c51 IDH.dh_c51 IHK.hkdf_expand256 IHK.hkdf_extract256
let setupBaseR = hpke_setupBaseR_higher #cs True IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.dh_c51 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c51 | false | true | Hacl.HPKE.Curve51_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sealBase: sealBase_st cs True | [] | Hacl.HPKE.Curve51_CP128_SHA512.sealBase | {
"file_name": "code/hpke/Hacl.HPKE.Curve51_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.sealBase_st Hacl.HPKE.Curve51_CP128_SHA512.cs Prims.l_True | {
"end_col": 80,
"end_line": 18,
"start_col": 15,
"start_line": 18
} |
Prims.Tot | val openBase: openBase_st cs True | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let openBase = hpke_openBase_higher #cs True IAEAD.aead_decrypt_cp128 setupBaseR | val openBase: openBase_st cs True
let openBase = | false | null | false | hpke_openBase_higher #cs True IAEAD.aead_decrypt_cp128 setupBaseR | {
"checked_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_openBase_higher",
"Hacl.HPKE.Curve51_CP128_SHA512.cs",
"Prims.l_True",
"Hacl.HPKE.Interface.AEAD.aead_decrypt_cp128",
"Hacl.HPKE.Curve51_CP128_SHA512.setupBaseR"
] | [] | module Hacl.HPKE.Curve51_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0"
let setupBaseS = hpke_setupBaseS_higher #cs True IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c51 IDH.dh_c51 IHK.hkdf_expand256 IHK.hkdf_extract256
let setupBaseR = hpke_setupBaseR_higher #cs True IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.dh_c51 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c51
let sealBase = hpke_sealBase_higher #cs True IAEAD.aead_encrypt_cp128 setupBaseS | false | true | Hacl.HPKE.Curve51_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val openBase: openBase_st cs True | [] | Hacl.HPKE.Curve51_CP128_SHA512.openBase | {
"file_name": "code/hpke/Hacl.HPKE.Curve51_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.openBase_st Hacl.HPKE.Curve51_CP128_SHA512.cs Prims.l_True | {
"end_col": 80,
"end_line": 20,
"start_col": 15,
"start_line": 20
} |
Prims.Tot | val setupBaseS: setupBaseS_st cs True | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let setupBaseS = hpke_setupBaseS_higher #cs True IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c51 IDH.dh_c51 IHK.hkdf_expand256 IHK.hkdf_extract256 | val setupBaseS: setupBaseS_st cs True
let setupBaseS = | false | null | false | hpke_setupBaseS_higher #cs
True
IHK.hkdf_expand512
IHK.hkdf_extract512
IDH.secret_to_public_c51
IDH.dh_c51
IHK.hkdf_expand256
IHK.hkdf_extract256 | {
"checked_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_setupBaseS_higher",
"Hacl.HPKE.Curve51_CP128_SHA512.cs",
"Prims.l_True",
"Hacl.HPKE.Interface.HKDF.hkdf_expand512",
"Hacl.HPKE.Interface.HKDF.hkdf_extract512",
"Hacl.HPKE.Interface.DH.secret_to_public_c51",
"Hacl.HPKE.Interface.DH.dh_c51",
"Hacl.HPKE.Interface.HKDF.hkdf_expand256",
"Hacl.HPKE.Interface.HKDF.hkdf_extract256"
] | [] | module Hacl.HPKE.Curve51_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0" | false | true | Hacl.HPKE.Curve51_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val setupBaseS: setupBaseS_st cs True | [] | Hacl.HPKE.Curve51_CP128_SHA512.setupBaseS | {
"file_name": "code/hpke/Hacl.HPKE.Curve51_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.setupBaseS_st Hacl.HPKE.Curve51_CP128_SHA512.cs Prims.l_True | {
"end_col": 162,
"end_line": 14,
"start_col": 17,
"start_line": 14
} |
Prims.Tot | val setupBaseR: setupBaseR_st cs True | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let setupBaseR = hpke_setupBaseR_higher #cs True IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.dh_c51 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c51 | val setupBaseR: setupBaseR_st cs True
let setupBaseR = | false | null | false | hpke_setupBaseR_higher #cs
True
IHK.hkdf_expand512
IHK.hkdf_extract512
IDH.dh_c51
IHK.hkdf_expand256
IHK.hkdf_extract256
IDH.secret_to_public_c51 | {
"checked_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve51_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_setupBaseR_higher",
"Hacl.HPKE.Curve51_CP128_SHA512.cs",
"Prims.l_True",
"Hacl.HPKE.Interface.HKDF.hkdf_expand512",
"Hacl.HPKE.Interface.HKDF.hkdf_extract512",
"Hacl.HPKE.Interface.DH.dh_c51",
"Hacl.HPKE.Interface.HKDF.hkdf_expand256",
"Hacl.HPKE.Interface.HKDF.hkdf_extract256",
"Hacl.HPKE.Interface.DH.secret_to_public_c51"
] | [] | module Hacl.HPKE.Curve51_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0"
let setupBaseS = hpke_setupBaseS_higher #cs True IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c51 IDH.dh_c51 IHK.hkdf_expand256 IHK.hkdf_extract256 | false | true | Hacl.HPKE.Curve51_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val setupBaseR: setupBaseR_st cs True | [] | Hacl.HPKE.Curve51_CP128_SHA512.setupBaseR | {
"file_name": "code/hpke/Hacl.HPKE.Curve51_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.setupBaseR_st Hacl.HPKE.Curve51_CP128_SHA512.cs Prims.l_True | {
"end_col": 162,
"end_line": 16,
"start_col": 17,
"start_line": 16
} |
Prims.Tot | val modifies_stack (lo_r1 hi_r1: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h' | val modifies_stack (lo_r1 hi_r1: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0
let modifies_stack (lo_r1 hi_r1: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 = | false | null | false | forall addr. {:pattern (load_stack64 addr h')\/(valid_src_stack64 addr h')}
valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' | {
"checked_file": "Vale.PPC64LE.Stack_i.fsti.checked",
"dependencies": [
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Stack_i.fsti"
} | [
"total"
] | [
"Prims.nat",
"Vale.PPC64LE.Stack_i.vale_stack",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Stack_i.valid_src_stack64",
"Prims.op_BarBar",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.op_GreaterThanOrEqual",
"Prims.eq2",
"Vale.PPC64LE.Memory.nat64",
"Vale.PPC64LE.Stack_i.load_stack64",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Stack_i
open FStar.Mul
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val init_r1 (h:vale_stack) : (n:nat64{n >= 65536}) | false | true | Vale.PPC64LE.Stack_i.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_stack (lo_r1 hi_r1: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 | [] | Vale.PPC64LE.Stack_i.modifies_stack | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
lo_r1: Prims.nat ->
hi_r1: Prims.nat ->
h: Vale.PPC64LE.Stack_i.vale_stack ->
h': Vale.PPC64LE.Stack_i.vale_stack
-> Vale.Def.Prop_s.prop0 | {
"end_col": 49,
"end_line": 26,
"start_col": 2,
"start_line": 23
} |
Prims.Tot | val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h | val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0
let valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 = | false | null | false | forall addr. {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h | {
"checked_file": "Vale.PPC64LE.Stack_i.fsti.checked",
"dependencies": [
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Stack_i.fsti"
} | [
"total"
] | [
"Prims.nat",
"Vale.PPC64LE.Stack_i.vale_stack",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Equality",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Vale.PPC64LE.Stack_i.valid_src_stack64",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Stack_i
open FStar.Mul
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val init_r1 (h:vale_stack) : (n:nat64{n >= 65536})
let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h' | false | true | Vale.PPC64LE.Stack_i.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 | [] | Vale.PPC64LE.Stack_i.valid_src_stack64s | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | base: Prims.nat -> num_slots: Prims.nat -> h: Vale.PPC64LE.Stack_i.vale_stack
-> Vale.Def.Prop_s.prop0 | {
"end_col": 30,
"end_line": 31,
"start_col": 2,
"start_line": 29
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) =
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint | let valid_stack_slot64 (ptr: int) (h: vale_stack) (t: taint) (stackTaint: memtaint) = | false | null | false | valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint | {
"checked_file": "Vale.PPC64LE.Stack_i.fsti.checked",
"dependencies": [
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Stack_i.fsti"
} | [
"total"
] | [
"Prims.int",
"Vale.PPC64LE.Stack_i.vale_stack",
"Vale.Arch.HeapTypes_s.taint",
"Vale.PPC64LE.Memory.memtaint",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Stack_i.valid_src_stack64",
"Vale.PPC64LE.Stack_i.valid_taint_stack64",
"Prims.logical"
] | [] | module Vale.PPC64LE.Stack_i
open FStar.Mul
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val init_r1 (h:vale_stack) : (n:nat64{n >= 65536})
let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h'
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h
(* Validity preservation *)
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))]
val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack128 i h /\
(i >= ptr + 16 \/ i + 16 <= ptr))
(ensures valid_src_stack128 i (store_stack128 ptr v h))
[SMTPat (valid_src_stack128 i (store_stack128 ptr v h))]
val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack128 ptr h /\
(ptr >= finish \/ ptr + 16 <= start))
(ensures valid_src_stack128 ptr (free_stack128 start finish h))
[SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))]
(* Validity update *)
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(valid_src_stack128 ptr (store_stack128 ptr v h))
[SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))]
(* Classic select/update lemmas *)
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))]
val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(load_stack128 ptr (store_stack128 ptr v h) == v)
[SMTPat (load_stack128 ptr (store_stack128 ptr v h))]
val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack128 i h /\
(i >= ptr + 16 \/ i + 16 <= ptr))
(ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h))
[SMTPat (load_stack128 i (store_stack128 ptr v h))]
val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack128 ptr h /\
(ptr >= finish \/ ptr + 16 <= start))
(ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h))
[SMTPat (load_stack128 ptr (free_stack128 start finish h))]
(* Free composition *)
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
(* Preservation of the initial stack pointer *)
val lemma_same_init_r1_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_r1 (free_stack64 start finish h) == init_r1 h)
[SMTPat (init_r1 (free_stack64 start finish h))]
val lemma_same_init_r1_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(init_r1 (store_stack64 ptr v h) == init_r1 h)
[SMTPat (init_r1 (store_stack64 ptr v h))]
val lemma_same_init_r1_free_stack128 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_r1 (free_stack128 start finish h) == init_r1 h)
[SMTPat (init_r1 (free_stack128 start finish h))]
val lemma_same_init_r1_store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(init_r1 (store_stack128 ptr v h) == init_r1 h)
[SMTPat (init_r1 (store_stack128 ptr v h))]
// Taint for the stack
val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val store_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack64 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack128 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack64 ptr t stackTaint)
val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 8 \/ i + 8 <= ptr)
(ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))]
val lemma_valid_taint_stack128_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack128 ptr t stackTaint)
val lemma_correct_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))
[SMTPat (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 16 \/ i + 16 <= ptr)
(ensures valid_taint_stack128 i t' stackTaint == valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))
[SMTPat (valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))] | false | true | Vale.PPC64LE.Stack_i.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_stack_slot64 : ptr: Prims.int ->
h: Vale.PPC64LE.Stack_i.vale_stack ->
t: Vale.Arch.HeapTypes_s.taint ->
stackTaint: Vale.PPC64LE.Memory.memtaint
-> Prims.logical | [] | Vale.PPC64LE.Stack_i.valid_stack_slot64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
ptr: Prims.int ->
h: Vale.PPC64LE.Stack_i.vale_stack ->
t: Vale.Arch.HeapTypes_s.taint ->
stackTaint: Vale.PPC64LE.Memory.memtaint
-> Prims.logical | {
"end_col": 65,
"end_line": 168,
"start_col": 2,
"start_line": 168
} |
|
Prims.Tot | val modifies_stacktaint (lo_r1 hi_r1: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_stacktaint (lo_r1 hi_r1:nat) (h h':memtaint) : Vale.Def.Prop_s.prop0 =
forall addr t. {:pattern (valid_taint_stack64 addr t h') }
(addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_taint_stack64 addr t h == valid_taint_stack64 addr t h' | val modifies_stacktaint (lo_r1 hi_r1: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0
let modifies_stacktaint (lo_r1 hi_r1: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 = | false | null | false | forall addr t. {:pattern (valid_taint_stack64 addr t h')}
(addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_taint_stack64 addr t h == valid_taint_stack64 addr t h' | {
"checked_file": "Vale.PPC64LE.Stack_i.fsti.checked",
"dependencies": [
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Stack_i.fsti"
} | [
"total"
] | [
"Prims.nat",
"Vale.PPC64LE.Memory.memtaint",
"Prims.l_Forall",
"Prims.int",
"Vale.Arch.HeapTypes_s.taint",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_BarBar",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.op_GreaterThanOrEqual",
"Prims.eq2",
"Vale.Def.Prop_s.prop0",
"Vale.PPC64LE.Stack_i.valid_taint_stack64"
] | [] | module Vale.PPC64LE.Stack_i
open FStar.Mul
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val init_r1 (h:vale_stack) : (n:nat64{n >= 65536})
let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h'
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h
(* Validity preservation *)
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))]
val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack128 i h /\
(i >= ptr + 16 \/ i + 16 <= ptr))
(ensures valid_src_stack128 i (store_stack128 ptr v h))
[SMTPat (valid_src_stack128 i (store_stack128 ptr v h))]
val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack128 ptr h /\
(ptr >= finish \/ ptr + 16 <= start))
(ensures valid_src_stack128 ptr (free_stack128 start finish h))
[SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))]
(* Validity update *)
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(valid_src_stack128 ptr (store_stack128 ptr v h))
[SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))]
(* Classic select/update lemmas *)
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))]
val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(load_stack128 ptr (store_stack128 ptr v h) == v)
[SMTPat (load_stack128 ptr (store_stack128 ptr v h))]
val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack128 i h /\
(i >= ptr + 16 \/ i + 16 <= ptr))
(ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h))
[SMTPat (load_stack128 i (store_stack128 ptr v h))]
val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack128 ptr h /\
(ptr >= finish \/ ptr + 16 <= start))
(ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h))
[SMTPat (load_stack128 ptr (free_stack128 start finish h))]
(* Free composition *)
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
(* Preservation of the initial stack pointer *)
val lemma_same_init_r1_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_r1 (free_stack64 start finish h) == init_r1 h)
[SMTPat (init_r1 (free_stack64 start finish h))]
val lemma_same_init_r1_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(init_r1 (store_stack64 ptr v h) == init_r1 h)
[SMTPat (init_r1 (store_stack64 ptr v h))]
val lemma_same_init_r1_free_stack128 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_r1 (free_stack128 start finish h) == init_r1 h)
[SMTPat (init_r1 (free_stack128 start finish h))]
val lemma_same_init_r1_store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(init_r1 (store_stack128 ptr v h) == init_r1 h)
[SMTPat (init_r1 (store_stack128 ptr v h))]
// Taint for the stack
val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val store_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack64 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack128 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack64 ptr t stackTaint)
val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 8 \/ i + 8 <= ptr)
(ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))]
val lemma_valid_taint_stack128_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack128 ptr t stackTaint)
val lemma_correct_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))
[SMTPat (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 16 \/ i + 16 <= ptr)
(ensures valid_taint_stack128 i t' stackTaint == valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))
[SMTPat (valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))]
let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) =
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/
(valid_stack_slot64 addr h t stackTaint)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint | false | true | Vale.PPC64LE.Stack_i.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_stacktaint (lo_r1 hi_r1: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 | [] | Vale.PPC64LE.Stack_i.modifies_stacktaint | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
lo_r1: Prims.nat ->
hi_r1: Prims.nat ->
h: Vale.PPC64LE.Memory.memtaint ->
h': Vale.PPC64LE.Memory.memtaint
-> Vale.Def.Prop_s.prop0 | {
"end_col": 67,
"end_line": 179,
"start_col": 2,
"start_line": 177
} |
Prims.Tot | val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint)
: Vale.Def.Prop_s.prop0 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/
(valid_stack_slot64 addr h t stackTaint)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint | val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint)
: Vale.Def.Prop_s.prop0
let valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint)
: Vale.Def.Prop_s.prop0 = | false | null | false | forall addr.
{:pattern
(valid_src_stack64 addr h)\/(valid_taint_stack64 addr t stackTaint)\/(valid_stack_slot64 addr
h
t
stackTaint)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint | {
"checked_file": "Vale.PPC64LE.Stack_i.fsti.checked",
"dependencies": [
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Stack_i.fsti"
} | [
"total"
] | [
"Prims.nat",
"Vale.PPC64LE.Stack_i.vale_stack",
"Vale.Arch.HeapTypes_s.taint",
"Vale.PPC64LE.Memory.memtaint",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Equality",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Prims.l_and",
"Vale.PPC64LE.Stack_i.valid_src_stack64",
"Vale.PPC64LE.Stack_i.valid_taint_stack64",
"Vale.PPC64LE.Stack_i.valid_stack_slot64",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Stack_i
open FStar.Mul
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val init_r1 (h:vale_stack) : (n:nat64{n >= 65536})
let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h'
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h
(* Validity preservation *)
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))]
val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack128 i h /\
(i >= ptr + 16 \/ i + 16 <= ptr))
(ensures valid_src_stack128 i (store_stack128 ptr v h))
[SMTPat (valid_src_stack128 i (store_stack128 ptr v h))]
val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack128 ptr h /\
(ptr >= finish \/ ptr + 16 <= start))
(ensures valid_src_stack128 ptr (free_stack128 start finish h))
[SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))]
(* Validity update *)
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(valid_src_stack128 ptr (store_stack128 ptr v h))
[SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))]
(* Classic select/update lemmas *)
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))]
val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(load_stack128 ptr (store_stack128 ptr v h) == v)
[SMTPat (load_stack128 ptr (store_stack128 ptr v h))]
val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack128 i h /\
(i >= ptr + 16 \/ i + 16 <= ptr))
(ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h))
[SMTPat (load_stack128 i (store_stack128 ptr v h))]
val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack128 ptr h /\
(ptr >= finish \/ ptr + 16 <= start))
(ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h))
[SMTPat (load_stack128 ptr (free_stack128 start finish h))]
(* Free composition *)
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
(* Preservation of the initial stack pointer *)
val lemma_same_init_r1_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_r1 (free_stack64 start finish h) == init_r1 h)
[SMTPat (init_r1 (free_stack64 start finish h))]
val lemma_same_init_r1_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(init_r1 (store_stack64 ptr v h) == init_r1 h)
[SMTPat (init_r1 (store_stack64 ptr v h))]
val lemma_same_init_r1_free_stack128 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_r1 (free_stack128 start finish h) == init_r1 h)
[SMTPat (init_r1 (free_stack128 start finish h))]
val lemma_same_init_r1_store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma
(init_r1 (store_stack128 ptr v h) == init_r1 h)
[SMTPat (init_r1 (store_stack128 ptr v h))]
// Taint for the stack
val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val store_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack64 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack128 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack64 ptr t stackTaint)
val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 8 \/ i + 8 <= ptr)
(ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))]
val lemma_valid_taint_stack128_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack128 ptr t stackTaint)
val lemma_correct_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))
[SMTPat (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 16 \/ i + 16 <= ptr)
(ensures valid_taint_stack128 i t' stackTaint == valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))
[SMTPat (valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))]
let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) =
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint | false | true | Vale.PPC64LE.Stack_i.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint)
: Vale.Def.Prop_s.prop0 | [] | Vale.PPC64LE.Stack_i.valid_stack_slot64s | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
base: Prims.nat ->
num_slots: Prims.nat ->
h: Vale.PPC64LE.Stack_i.vale_stack ->
t: Vale.Arch.HeapTypes_s.taint ->
stackTaint: Vale.PPC64LE.Memory.memtaint
-> Vale.Def.Prop_s.prop0 | {
"end_col": 71,
"end_line": 174,
"start_col": 2,
"start_line": 171
} |
Prims.Tot | val sub_borrow_u64: sub_borrow_st U64 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub_borrow_u64 cin x y r = sub_borrow_fallback #U64 cin x y r | val sub_borrow_u64: sub_borrow_st U64
let sub_borrow_u64 cin x y r = | false | null | false | sub_borrow_fallback #U64 cin x y r | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"Hacl.IntTypes.Intrinsics.sub_borrow_fallback"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c
inline_for_extraction noextract
let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin))
val sub_borrow_u32: sub_borrow_st U32
let sub_borrow_u32 cin x y r =
let res = to_u64 x -. to_u64 y -. to_u64 cin in
assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64);
Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64);
assert (v res == (v x - v y - v cin) % pow2 64);
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32);
Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64;
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32);
let c = to_u32 (res >>. 32ul) &. u32 1 in
assert_norm (pow2 1 = 2);
mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul;
assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1);
assert (v c = v res / pow2 32 % pow2 1);
r.(0ul) <- to_u32 res;
assert (v c = (if 0 <= v x - v y - v cin then 0 else 1));
c
(* Fallback versions of add_carry_u64 and sub_borrow_u64 for platforms which
don't support uint128.
The names Hacl.IntTypes.Intrinsics.add_carry_u64 and sub_borrow_u64 must not
be changed because they are hardcoded in KaRaMeL for extracting wasm code
which uses these intrinsics. *)
inline_for_extraction noextract
val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t
let add_carry_fallback #t cin x y r =
let res = x +. cin +. y in
let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
r.(0ul) <- res;
logand_lemma (eq_mask res x) cin;
logor_lemma (lt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
c
val add_carry_u64: add_carry_st U64
let add_carry_u64 cin x y r = add_carry_fallback #U64 cin x y r
inline_for_extraction noextract
val sub_borrow_fallback: #t:inttype{t = U32 \/ t = U64} -> sub_borrow_st t
let sub_borrow_fallback #t cin x y r =
let res = x -. y -. cin in
let c = logand (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
logand_lemma (eq_mask res x) cin;
logor_lemma (gt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
r.(0ul) <- res;
c | false | true | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub_borrow_u64: sub_borrow_st U64 | [] | Hacl.IntTypes.Intrinsics.sub_borrow_u64 | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.IntTypes.Intrinsics.sub_borrow_st Lib.IntTypes.U64 | {
"end_col": 65,
"end_line": 100,
"start_col": 31,
"start_line": 100
} |
Prims.Tot | val add_carry_u64: add_carry_st U64 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_carry_u64 cin x y r = add_carry_fallback #U64 cin x y r | val add_carry_u64: add_carry_st U64
let add_carry_u64 cin x y r = | false | null | false | add_carry_fallback #U64 cin x y r | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"Hacl.IntTypes.Intrinsics.add_carry_fallback"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c
inline_for_extraction noextract
let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin))
val sub_borrow_u32: sub_borrow_st U32
let sub_borrow_u32 cin x y r =
let res = to_u64 x -. to_u64 y -. to_u64 cin in
assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64);
Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64);
assert (v res == (v x - v y - v cin) % pow2 64);
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32);
Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64;
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32);
let c = to_u32 (res >>. 32ul) &. u32 1 in
assert_norm (pow2 1 = 2);
mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul;
assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1);
assert (v c = v res / pow2 32 % pow2 1);
r.(0ul) <- to_u32 res;
assert (v c = (if 0 <= v x - v y - v cin then 0 else 1));
c
(* Fallback versions of add_carry_u64 and sub_borrow_u64 for platforms which
don't support uint128.
The names Hacl.IntTypes.Intrinsics.add_carry_u64 and sub_borrow_u64 must not
be changed because they are hardcoded in KaRaMeL for extracting wasm code
which uses these intrinsics. *)
inline_for_extraction noextract
val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t
let add_carry_fallback #t cin x y r =
let res = x +. cin +. y in
let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
r.(0ul) <- res;
logand_lemma (eq_mask res x) cin;
logor_lemma (lt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
c | false | true | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add_carry_u64: add_carry_st U64 | [] | Hacl.IntTypes.Intrinsics.add_carry_u64 | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.IntTypes.Intrinsics.add_carry_st Lib.IntTypes.U64 | {
"end_col": 63,
"end_line": 86,
"start_col": 30,
"start_line": 86
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin)) | let add_carry_st (t: inttype{t = U32 \/ t = U64}) = | false | null | false | cin: uint_t t SEC -> x: uint_t t SEC -> y: uint_t t SEC -> r: lbuffer (uint_t t SEC) (size 1)
-> Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures
fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin)) | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.Buffer.modifies1",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.bits",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.index",
"Lib.Buffer.as_seq"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract | false | false | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add_carry_st : t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | [] | Hacl.IntTypes.Intrinsics.add_carry_st | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | {
"end_col": 52,
"end_line": 25,
"start_col": 4,
"start_line": 16
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin)) | let sub_borrow_st (t: inttype{t = U32 \/ t = U64}) = | false | null | false | cin: uint_t t SEC -> x: uint_t t SEC -> y: uint_t t SEC -> r: lbuffer (uint_t t SEC) (size 1)
-> Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures
fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin)) | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.Buffer.modifies1",
"Prims.eq2",
"Prims.int",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.bits",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.index",
"Lib.Buffer.as_seq"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c
inline_for_extraction noextract | false | false | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub_borrow_st : t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | [] | Hacl.IntTypes.Intrinsics.sub_borrow_st | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | {
"end_col": 52,
"end_line": 45,
"start_col": 4,
"start_line": 36
} |
|
Prims.Tot | val sub_borrow_fallback: #t:inttype{t = U32 \/ t = U64} -> sub_borrow_st t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub_borrow_fallback #t cin x y r =
let res = x -. y -. cin in
let c = logand (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
logand_lemma (eq_mask res x) cin;
logor_lemma (gt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
r.(0ul) <- res;
c | val sub_borrow_fallback: #t:inttype{t = U32 \/ t = U64} -> sub_borrow_st t
let sub_borrow_fallback #t cin x y r = | false | null | false | let res = x -. y -. cin in
let c = logand (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
logand_lemma (eq_mask res x) cin;
logor_lemma (gt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
r.(0ul) <- res;
c | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.logand_mask",
"Lib.IntTypes.logor",
"Lib.IntTypes.gt_mask",
"Lib.IntTypes.logand",
"Lib.IntTypes.eq_mask",
"Lib.IntTypes.uint",
"Lib.IntTypes.logor_lemma",
"Lib.IntTypes.logand_lemma",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Subtraction_Dot"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c
inline_for_extraction noextract
let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin))
val sub_borrow_u32: sub_borrow_st U32
let sub_borrow_u32 cin x y r =
let res = to_u64 x -. to_u64 y -. to_u64 cin in
assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64);
Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64);
assert (v res == (v x - v y - v cin) % pow2 64);
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32);
Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64;
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32);
let c = to_u32 (res >>. 32ul) &. u32 1 in
assert_norm (pow2 1 = 2);
mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul;
assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1);
assert (v c = v res / pow2 32 % pow2 1);
r.(0ul) <- to_u32 res;
assert (v c = (if 0 <= v x - v y - v cin then 0 else 1));
c
(* Fallback versions of add_carry_u64 and sub_borrow_u64 for platforms which
don't support uint128.
The names Hacl.IntTypes.Intrinsics.add_carry_u64 and sub_borrow_u64 must not
be changed because they are hardcoded in KaRaMeL for extracting wasm code
which uses these intrinsics. *)
inline_for_extraction noextract
val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t
let add_carry_fallback #t cin x y r =
let res = x +. cin +. y in
let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
r.(0ul) <- res;
logand_lemma (eq_mask res x) cin;
logor_lemma (lt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
c
val add_carry_u64: add_carry_st U64
let add_carry_u64 cin x y r = add_carry_fallback #U64 cin x y r
inline_for_extraction noextract | false | false | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub_borrow_fallback: #t:inttype{t = U32 \/ t = U64} -> sub_borrow_st t | [] | Hacl.IntTypes.Intrinsics.sub_borrow_fallback | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.IntTypes.Intrinsics.sub_borrow_st t | {
"end_col": 3,
"end_line": 97,
"start_col": 38,
"start_line": 90
} |
Prims.Tot | val sub_borrow_u32: sub_borrow_st U32 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub_borrow_u32 cin x y r =
let res = to_u64 x -. to_u64 y -. to_u64 cin in
assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64);
Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64);
assert (v res == (v x - v y - v cin) % pow2 64);
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32);
Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64;
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32);
let c = to_u32 (res >>. 32ul) &. u32 1 in
assert_norm (pow2 1 = 2);
mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul;
assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1);
assert (v c = v res / pow2 32 % pow2 1);
r.(0ul) <- to_u32 res;
assert (v c = (if 0 <= v x - v y - v cin then 0 else 1));
c | val sub_borrow_u32: sub_borrow_st U32
let sub_borrow_u32 cin x y r = | false | null | false | let res = to_u64 x -. to_u64 y -. to_u64 cin in
assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64);
Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64);
assert (v res == (v x - v y - v cin) % pow2 64);
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32);
Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64;
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32);
let c = to_u32 (res >>. 32ul) &. u32 1 in
assert_norm (pow2 1 = 2);
mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul;
assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1);
assert (v c = v res / pow2 32 % pow2 1);
r.(0ul) <- to_u32 res;
assert (v c = (if 0 <= v x - v y - v cin then 0 else 1));
c | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"Prims.unit",
"Prims._assert",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.bool",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.to_u32",
"Lib.IntTypes.U64",
"Prims.op_Modulus",
"Prims.op_Division",
"Prims.pow2",
"Prims.eq2",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.mod_mask_lemma",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.Pervasives.assert_norm",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.u32",
"FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1",
"FStar.Math.Lemmas.lemma_mod_add_distr",
"Prims.op_Minus",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.to_u64"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c
inline_for_extraction noextract
let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin)) | false | true | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub_borrow_u32: sub_borrow_st U32 | [] | Hacl.IntTypes.Intrinsics.sub_borrow_u32 | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.IntTypes.Intrinsics.sub_borrow_st Lib.IntTypes.U32 | {
"end_col": 3,
"end_line": 66,
"start_col": 30,
"start_line": 48
} |
Prims.Tot | val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_carry_fallback #t cin x y r =
let res = x +. cin +. y in
let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
r.(0ul) <- res;
logand_lemma (eq_mask res x) cin;
logor_lemma (lt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
c | val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t
let add_carry_fallback #t cin x y r = | false | null | false | let res = x +. cin +. y in
let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in
r.(0ul) <- res;
logand_lemma (eq_mask res x) cin;
logor_lemma (lt_mask res x) (logand (eq_mask res x) cin);
logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1;
c | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"Prims.unit",
"Lib.IntTypes.logand_mask",
"Lib.IntTypes.logor",
"Lib.IntTypes.lt_mask",
"Lib.IntTypes.logand",
"Lib.IntTypes.eq_mask",
"Lib.IntTypes.uint",
"Lib.IntTypes.logor_lemma",
"Lib.IntTypes.logand_lemma",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Dot"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c
inline_for_extraction noextract
let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin))
val sub_borrow_u32: sub_borrow_st U32
let sub_borrow_u32 cin x y r =
let res = to_u64 x -. to_u64 y -. to_u64 cin in
assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64);
Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64);
assert (v res == (v x - v y - v cin) % pow2 64);
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32);
Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64;
assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32);
let c = to_u32 (res >>. 32ul) &. u32 1 in
assert_norm (pow2 1 = 2);
mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul;
assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1);
assert (v c = v res / pow2 32 % pow2 1);
r.(0ul) <- to_u32 res;
assert (v c = (if 0 <= v x - v y - v cin then 0 else 1));
c
(* Fallback versions of add_carry_u64 and sub_borrow_u64 for platforms which
don't support uint128.
The names Hacl.IntTypes.Intrinsics.add_carry_u64 and sub_borrow_u64 must not
be changed because they are hardcoded in KaRaMeL for extracting wasm code
which uses these intrinsics. *)
inline_for_extraction noextract | false | false | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t | [] | Hacl.IntTypes.Intrinsics.add_carry_fallback | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.IntTypes.Intrinsics.add_carry_st t | {
"end_col": 3,
"end_line": 83,
"start_col": 37,
"start_line": 76
} |
Prims.Tot | val add_carry_u32: add_carry_st U32 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c | val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r = | false | null | false | let res = to_u64 x +. to_u64 cin +. to_u64 y in
let c = to_u32 (res >>. 32ul) in
r.(0ul) <- to_u32 res;
c | {
"checked_file": "Hacl.IntTypes.Intrinsics.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.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.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.IntTypes.Intrinsics.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.to_u32",
"Lib.IntTypes.U64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.to_u64"
] | [] | module Hacl.IntTypes.Intrinsics
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
inline_for_extraction noextract
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin)) | false | true | Hacl.IntTypes.Intrinsics.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add_carry_u32: add_carry_st U32 | [] | Hacl.IntTypes.Intrinsics.add_carry_u32 | {
"file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.IntTypes.Intrinsics.add_carry_st Lib.IntTypes.U32 | {
"end_col": 3,
"end_line": 32,
"start_col": 29,
"start_line": 28
} |
FStar.Pervasives.Lemma | val addrs_set_lemma_all (_:unit) : Lemma
(forall (mem:interop_heap) (x:int).{:pattern (Set.mem x (addrs_set mem))}
let addrs = addrs_of_mem mem in
let ptrs = ptrs_of_mem mem in
valid_addr mem x <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc))) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma | val addrs_set_lemma_all (_:unit) : Lemma
(forall (mem:interop_heap) (x:int).{:pattern (Set.mem x (addrs_set mem))}
let addrs = addrs_of_mem mem in
let ptrs = ptrs_of_mem mem in
valid_addr mem x <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)))
let addrs_set_lemma_all () = | false | null | true | FStar.Classical.forall_intro_2 addrs_set_lemma | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Vale.Interop.Heap_s.interop_heap",
"Prims.int",
"Prims.l_iff",
"Prims.b2t",
"Vale.Interop.valid_addr",
"Prims.l_Exists",
"Vale.Interop.Types.b8",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.op_LessThan",
"Prims.op_Addition",
"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",
"Vale.Interop.addrs_set_lemma"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addrs_set_lemma_all (_:unit) : Lemma
(forall (mem:interop_heap) (x:int).{:pattern (Set.mem x (addrs_set mem))}
let addrs = addrs_of_mem mem in
let ptrs = ptrs_of_mem mem in
valid_addr mem x <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc))) | [] | Vale.Interop.addrs_set_lemma_all | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures
forall (mem: Vale.Interop.Heap_s.interop_heap) (x: Prims.int).
{:pattern FStar.Set.mem x (Vale.Interop.Heap_s.addrs_set mem)}
let addrs = Vale.Interop.Heap_s.addrs_of_mem mem in
let ptrs = Vale.Interop.Heap_s.ptrs_of_mem mem in
Vale.Interop.valid_addr mem x <==>
(exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}). {:pattern addrs b}
addrs b <= x /\
x <
addrs b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)))) | {
"end_col": 48,
"end_line": 200,
"start_col": 2,
"start_line": 200
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap | let write_buffer_vale (a: b8) (heap: machine_heap) (mem: interop_heap) = | false | null | false | let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"sometrivial"
] | [
"Vale.Interop.Types.b8",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.write_vale_mem",
"Vale.Def.Words_s.nat64",
"Vale.Interop.Heap_s.addrs_of_mem",
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.length",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"Prims.nat",
"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"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all () | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_buffer_vale : a: Vale.Interop.Types.b8 ->
heap: Vale.Arch.MachineHeap_s.machine_heap ->
mem: Vale.Interop.Heap_s.interop_heap
-> Prims.GTot Vale.Arch.MachineHeap_s.machine_heap | [] | Vale.Interop.write_buffer_vale | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Vale.Interop.Types.b8 ->
heap: Vale.Arch.MachineHeap_s.machine_heap ->
mem: Vale.Interop.Heap_s.interop_heap
-> Prims.GTot Vale.Arch.MachineHeap_s.machine_heap | {
"end_col": 44,
"end_line": 210,
"start_col": 69,
"start_line": 205
} |
|
FStar.Pervasives.Lemma | val addrs_set_lemma (mem:interop_heap) (x:int)
: Lemma (let addrs = addrs_of_mem mem in
let ptrs = ptrs_of_mem mem in
valid_addr mem x <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc))) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x | val addrs_set_lemma (mem:interop_heap) (x:int)
: Lemma (let addrs = addrs_of_mem mem in
let ptrs = ptrs_of_mem mem in
valid_addr mem x <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)))
let addrs_set_lemma mem x = | false | null | true | addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Prims.int",
"Vale.Interop.addrs_set_lemma_aux",
"Vale.Interop.Heap_s.addrs_of_mem",
"Vale.Interop.Heap_s.ptrs_of_mem",
"FStar.Set.empty",
"Prims.unit"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addrs_set_lemma (mem:interop_heap) (x:int)
: Lemma (let addrs = addrs_of_mem mem in
let ptrs = ptrs_of_mem mem in
valid_addr mem x <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc))) | [] | Vale.Interop.addrs_set_lemma | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | mem: Vale.Interop.Heap_s.interop_heap -> x: Prims.int
-> FStar.Pervasives.Lemma
(ensures
(let addrs = Vale.Interop.Heap_s.addrs_of_mem mem in
let ptrs = Vale.Interop.Heap_s.ptrs_of_mem mem in
Vale.Interop.valid_addr mem x <==>
(exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}). {:pattern addrs b}
addrs b <= x /\
x <
addrs b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b))))) | {
"end_col": 70,
"end_line": 197,
"start_col": 2,
"start_line": 197
} |
FStar.Pervasives.Lemma | val addrs_set_mem (mem:interop_heap) (a:b8) (i:int)
: Lemma
(requires (let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
List.memP a ptrs /\ i >= addrs a /\ i < addrs a + DV.length (get_downview a.bsrc)))
(ensures valid_addr mem i) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let addrs_set_mem mem a i =
addrs_set_lemma_all () | val addrs_set_mem (mem:interop_heap) (a:b8) (i:int)
: Lemma
(requires (let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
List.memP a ptrs /\ i >= addrs a /\ i < addrs a + DV.length (get_downview a.bsrc)))
(ensures valid_addr mem i)
let addrs_set_mem mem a i = | false | null | true | addrs_set_lemma_all () | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.Types.b8",
"Prims.int",
"Vale.Interop.addrs_set_lemma_all",
"Prims.unit"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addrs_set_mem (mem:interop_heap) (a:b8) (i:int)
: Lemma
(requires (let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
List.memP a ptrs /\ i >= addrs a /\ i < addrs a + DV.length (get_downview a.bsrc)))
(ensures valid_addr mem i) | [] | Vale.Interop.addrs_set_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | mem: Vale.Interop.Heap_s.interop_heap -> a: Vale.Interop.Types.b8 -> i: Prims.int
-> FStar.Pervasives.Lemma
(requires
(let ptrs = Vale.Interop.Heap_s.ptrs_of_mem mem in
let addrs = Vale.Interop.Heap_s.addrs_of_mem mem in
FStar.List.Tot.Base.memP a ptrs /\ i >= addrs a /\
i <
addrs a +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc a))))
(ensures Vale.Interop.valid_addr mem i) | {
"end_col": 24,
"end_line": 203,
"start_col": 2,
"start_line": 203
} |
Prims.GTot | val up_mem (heap:machine_heap) (mem:interop_heap{Set.equal (addrs_set mem) (Map.domain heap)})
: GTot (new_mem:interop_heap{ptrs_of_mem mem == ptrs_of_mem new_mem /\
correct_down new_mem heap}) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem | val up_mem (heap:machine_heap) (mem:interop_heap{Set.equal (addrs_set mem) (Map.domain heap)})
: GTot (new_mem:interop_heap{ptrs_of_mem mem == ptrs_of_mem new_mem /\
correct_down new_mem heap})
let up_mem heap mem = | false | null | false | up_mem_aux heap (ptrs_of_mem mem) [] mem | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.interop_heap",
"FStar.Set.equal",
"Prims.int",
"Vale.Interop.Heap_s.addrs_set",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Vale.Interop.up_mem_aux",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Prims.Nil",
"Vale.Interop.Types.b8",
"Prims.l_and",
"Prims.eq2",
"Prims.list",
"Prims.l_or",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.correct_down"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val up_mem (heap:machine_heap) (mem:interop_heap{Set.equal (addrs_set mem) (Map.domain heap)})
: GTot (new_mem:interop_heap{ptrs_of_mem mem == ptrs_of_mem new_mem /\
correct_down new_mem heap}) | [] | Vale.Interop.up_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
heap: Vale.Arch.MachineHeap_s.machine_heap ->
mem:
Vale.Interop.Heap_s.interop_heap
{FStar.Set.equal (Vale.Interop.Heap_s.addrs_set mem) (FStar.Map.domain heap)}
-> Prims.GTot
(new_mem:
Vale.Interop.Heap_s.interop_heap
{ Vale.Interop.Heap_s.ptrs_of_mem mem == Vale.Interop.Heap_s.ptrs_of_mem new_mem /\
Vale.Interop.Heap_s.correct_down new_mem heap }) | {
"end_col": 62,
"end_line": 382,
"start_col": 22,
"start_line": 382
} |
FStar.Pervasives.Lemma | val get_seq_heap_as_seq (heap1 heap2: machine_heap) (mem: interop_heap) (b: b8)
: Lemma
(requires
correct_down_p mem heap1 b /\
(forall x.
x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==>
heap1.[ x ] == heap2.[ x ]))
(ensures
DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) | val get_seq_heap_as_seq (heap1 heap2: machine_heap) (mem: interop_heap) (b: b8)
: Lemma
(requires
correct_down_p mem heap1 b /\
(forall x.
x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==>
heap1.[ x ] == heap2.[ x ]))
(ensures
DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b)
let get_seq_heap_as_seq (heap1 heap2: machine_heap) (mem: interop_heap) (b: b8)
: Lemma
(requires
correct_down_p mem heap1 b /\
(forall x.
x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==>
heap1.[ x ] == heap2.[ x ]))
(ensures
DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = | false | null | true | assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc))
(get_seq_heap heap2 (addrs_of_mem mem) b)) | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.Types.b8",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.UInt8.t",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"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",
"Vale.Interop.get_seq_heap",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.unit",
"Prims.l_and",
"Vale.Interop.Heap_s.correct_down_p",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"LowStar.BufferView.Down.length",
"Prims.eq2",
"Vale.Def.Types_s.nat8",
"Vale.Interop.op_String_Access",
"Prims.squash",
"FStar.Seq.Properties.lseq",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_seq_heap_as_seq (heap1 heap2: machine_heap) (mem: interop_heap) (b: b8)
: Lemma
(requires
correct_down_p mem heap1 b /\
(forall x.
x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==>
heap1.[ x ] == heap2.[ x ]))
(ensures
DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) | [] | Vale.Interop.get_seq_heap_as_seq | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
heap1: Vale.Arch.MachineHeap_s.machine_heap ->
heap2: Vale.Arch.MachineHeap_s.machine_heap ->
mem: Vale.Interop.Heap_s.interop_heap ->
b: Vale.Interop.Types.b8
-> FStar.Pervasives.Lemma
(requires
Vale.Interop.Heap_s.correct_down_p mem heap1 b /\
(forall (x: Prims.int).
x >= Vale.Interop.Heap_s.addrs_of_mem mem b /\
x <
Vale.Interop.Heap_s.addrs_of_mem mem b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==>
heap1.[ x ] == heap2.[ x ]))
(ensures
LowStar.BufferView.Down.as_seq (Vale.Interop.Heap_s.hs_of_mem mem)
(Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==
Vale.Interop.get_seq_heap heap2 (Vale.Interop.Heap_s.addrs_of_mem mem) b) | {
"end_col": 112,
"end_line": 355,
"start_col": 2,
"start_line": 355
} |
FStar.Pervasives.Lemma | val addrs_ptr_lemma
(i: nat)
(addrs: addr_map)
(ptr: b8{i <= DV.length (get_downview ptr.bsrc)})
(acc: Set.set int)
(x: int)
: Lemma (requires True)
(ensures
Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)
)
(decreases (DV.length (get_downview ptr.bsrc) - i)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x | val addrs_ptr_lemma
(i: nat)
(addrs: addr_map)
(ptr: b8{i <= DV.length (get_downview ptr.bsrc)})
(acc: Set.set int)
(x: int)
: Lemma (requires True)
(ensures
Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)
)
(decreases (DV.length (get_downview ptr.bsrc) - i))
let rec addrs_ptr_lemma
(i: nat)
(addrs: addr_map)
(ptr: b8{i <= DV.length (get_downview ptr.bsrc)})
(acc: Set.set int)
(x: int)
: Lemma (requires True)
(ensures
Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)
)
(decreases (DV.length (get_downview ptr.bsrc) - i)) = | false | null | true | if i = DV.length (get_downview ptr.bsrc)
then ()
else addrs_ptr_lemma (i + 1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma",
""
] | [
"Prims.nat",
"Vale.Interop.Types.addr_map",
"Vale.Interop.Types.b8",
"Prims.b2t",
"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",
"FStar.Set.set",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"Vale.Interop.addrs_ptr_lemma",
"Prims.op_Addition",
"FStar.Set.union",
"FStar.Set.singleton",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"FStar.Set.mem",
"Vale.Interop.Heap_s.addrs_ptr",
"Prims.l_or",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addrs_ptr_lemma
(i: nat)
(addrs: addr_map)
(ptr: b8{i <= DV.length (get_downview ptr.bsrc)})
(acc: Set.set int)
(x: int)
: Lemma (requires True)
(ensures
Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)
)
(decreases (DV.length (get_downview ptr.bsrc) - i)) | [
"recursion"
] | Vale.Interop.addrs_ptr_lemma | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Prims.nat ->
addrs: Vale.Interop.Types.addr_map ->
ptr:
Vale.Interop.Types.b8
{i <= LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc ptr))} ->
acc: FStar.Set.set Prims.int ->
x: Prims.int
-> FStar.Pervasives.Lemma
(ensures
FStar.Set.mem x (Vale.Interop.Heap_s.addrs_ptr i addrs ptr acc) <==>
addrs ptr + i <= x /\
x <
addrs ptr +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc ptr)) \/
FStar.Set.mem x acc)
(decreases
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc ptr)) - i) | {
"end_col": 88,
"end_line": 182,
"start_col": 2,
"start_line": 181
} |
FStar.Pervasives.Lemma | val up_down_identity_aux
(mem: interop_heap)
(init_heap: machine_heap{correct_down mem init_heap})
(x: int)
: Lemma (requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let up_down_identity_aux
(mem:interop_heap)
(init_heap:machine_heap{correct_down mem init_heap})
(x:int) : Lemma
(requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x) =
let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
addrs_set_lemma_all ();
Classical.forall_intro
(Classical.move_requires
(correct_down_p_same_sel mem (down_mem mem) init_heap x)
) | val up_down_identity_aux
(mem: interop_heap)
(init_heap: machine_heap{correct_down mem init_heap})
(x: int)
: Lemma (requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x)
let up_down_identity_aux
(mem: interop_heap)
(init_heap: machine_heap{correct_down mem init_heap})
(x: int)
: Lemma (requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x) = | false | null | true | let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
addrs_set_lemma_all ();
Classical.forall_intro (Classical.move_requires (correct_down_p_same_sel mem
(down_mem mem)
init_heap
x)) | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.correct_down",
"Prims.int",
"FStar.Classical.forall_intro",
"Vale.Interop.Types.b8",
"Prims.l_imp",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.op_LessThan",
"Prims.op_Addition",
"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",
"Vale.Interop.Heap_s.correct_down_p",
"Vale.Interop.down_mem",
"Prims.eq2",
"Vale.Def.Types_s.nat8",
"FStar.Map.sel",
"FStar.Classical.move_requires",
"Vale.Interop.correct_down_p_same_sel",
"Prims.unit",
"Vale.Interop.addrs_set_lemma_all",
"Vale.Interop.Types.addr_map",
"Prims.list",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.ptrs_of_mem",
"FStar.Map.contains",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)})
: Lemma (m == up_mem_aux h ps accu m) =
match ps with
| [] -> ()
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
(* The previous assertion and lemma ensure that m == m' *)
down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let down_up_identity mem =
let heap = down_mem mem in
down_up_identity_aux heap (ptrs_of_mem mem) [] mem
// Selecting a buffer index in any corresponding map of bytes always yields the same result
let correct_down_p_same_sel
(mem:interop_heap)
(heap1 heap2:machine_heap)
(x:int)
(b:b8) : Lemma
(requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)
/\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) =
let addrs = addrs_of_mem mem in
let i = x - addrs b in
assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i));
assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i))
let up_down_identity_aux
(mem:interop_heap)
(init_heap:machine_heap{correct_down mem init_heap})
(x:int) : Lemma | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val up_down_identity_aux
(mem: interop_heap)
(init_heap: machine_heap{correct_down mem init_heap})
(x: int)
: Lemma (requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x) | [] | Vale.Interop.up_down_identity_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Interop.Heap_s.interop_heap ->
init_heap: Vale.Arch.MachineHeap_s.machine_heap{Vale.Interop.Heap_s.correct_down mem init_heap} ->
x: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Map.contains init_heap x)
(ensures FStar.Map.sel init_heap x == FStar.Map.sel (Vale.Interop.down_mem mem) x) | {
"end_col": 5,
"end_line": 432,
"start_col": 61,
"start_line": 425
} |
FStar.Pervasives.Lemma | val correct_down_p_same_sel (mem: interop_heap) (heap1 heap2: machine_heap) (x: int) (b: b8)
: Lemma
(requires
(x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\
correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let correct_down_p_same_sel
(mem:interop_heap)
(heap1 heap2:machine_heap)
(x:int)
(b:b8) : Lemma
(requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)
/\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) =
let addrs = addrs_of_mem mem in
let i = x - addrs b in
assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i));
assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)) | val correct_down_p_same_sel (mem: interop_heap) (heap1 heap2: machine_heap) (x: int) (b: b8)
: Lemma
(requires
(x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\
correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x)
let correct_down_p_same_sel (mem: interop_heap) (heap1 heap2: machine_heap) (x: int) (b: b8)
: Lemma
(requires
(x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\
correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) = | false | null | true | let addrs = addrs_of_mem mem in
let i = x - addrs b in
assert (heap1.[ x ] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i));
assert (heap2.[ x ] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)) | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.int",
"Vale.Interop.Types.b8",
"Prims._assert",
"Prims.eq2",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_8",
"Vale.Interop.op_String_Access",
"Vale.Def.Types_s.nat8",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"FStar.UInt8.t",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"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",
"Prims.op_Subtraction",
"Vale.Interop.Types.addr_map",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.op_Addition",
"LowStar.BufferView.Down.length",
"Vale.Interop.Heap_s.correct_down_p",
"Prims.squash",
"FStar.Map.sel",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)})
: Lemma (m == up_mem_aux h ps accu m) =
match ps with
| [] -> ()
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
(* The previous assertion and lemma ensure that m == m' *)
down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let down_up_identity mem =
let heap = down_mem mem in
down_up_identity_aux heap (ptrs_of_mem mem) [] mem
// Selecting a buffer index in any corresponding map of bytes always yields the same result
let correct_down_p_same_sel
(mem:interop_heap)
(heap1 heap2:machine_heap)
(x:int)
(b:b8) : Lemma
(requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val correct_down_p_same_sel (mem: interop_heap) (heap1 heap2: machine_heap) (x: int) (b: b8)
: Lemma
(requires
(x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\
correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) | [] | Vale.Interop.correct_down_p_same_sel | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Interop.Heap_s.interop_heap ->
heap1: Vale.Arch.MachineHeap_s.machine_heap ->
heap2: Vale.Arch.MachineHeap_s.machine_heap ->
x: Prims.int ->
b: Vale.Interop.Types.b8
-> FStar.Pervasives.Lemma
(requires
x >= Vale.Interop.Heap_s.addrs_of_mem mem b /\
x <
Vale.Interop.Heap_s.addrs_of_mem mem b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) /\
Vale.Interop.Heap_s.correct_down_p mem heap1 b /\
Vale.Interop.Heap_s.correct_down_p mem heap2 b)
(ensures FStar.Map.sel heap1 x == FStar.Map.sel heap2 x) | {
"end_col": 97,
"end_line": 418,
"start_col": 48,
"start_line": 414
} |
Prims.GTot | val down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
: GTot
(heap:
machine_heap
{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap | val down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
: GTot
(heap:
machine_heap
{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p})
let rec down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
: GTot
(heap:
machine_heap
{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = | false | null | false | match ps with
| [] -> h
| a :: q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a :: accu) new_heap | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"sometrivial"
] | [
"Prims.list",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.interop_heap",
"Prims.l_Forall",
"Prims.l_iff",
"FStar.List.Tot.Base.memP",
"Prims.l_or",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_imp",
"Vale.Interop.Heap_s.correct_down_p",
"Vale.Interop.down_mem_aux",
"Prims.Cons",
"Prims.unit",
"Vale.Interop.Heap_s.list_disjoint_or_eq_reveal",
"Vale.Interop.correct_down_p_frame",
"Vale.Interop.correct_down_p_cancel",
"Vale.Interop.load_store_write_vale_mem",
"Vale.Def.Words_s.nat64",
"Vale.Interop.Heap_s.addrs_of_mem",
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.length",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"Prims.nat",
"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",
"Vale.Interop.write_buffer_vale"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs} | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
: GTot
(heap:
machine_heap
{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) | [
"recursion"
] | Vale.Interop.down_mem_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
ptrs: Prims.list Vale.Interop.Types.b8 {Vale.Interop.Heap_s.list_disjoint_or_eq ptrs} ->
mem: Vale.Interop.Heap_s.interop_heap ->
ps: Prims.list Vale.Interop.Types.b8 ->
accu:
Prims.list Vale.Interop.Types.b8
{ forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p ptrs <==>
FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu } ->
h:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (p: Vale.Interop.Types.b8). {:pattern FStar.List.Tot.Base.memP p accu}
FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p mem h p }
-> Prims.GTot
(heap:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (p: Vale.Interop.Types.b8). {:pattern FStar.List.Tot.Base.memP p ptrs}
FStar.List.Tot.Base.memP p ptrs ==> Vale.Interop.Heap_s.correct_down_p mem heap p }) | {
"end_col": 48,
"end_line": 233,
"start_col": 2,
"start_line": 221
} |
FStar.Pervasives.Lemma | val down_up_identity (mem:interop_heap)
: Lemma (mem == up_mem (down_mem mem) mem) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let down_up_identity mem =
let heap = down_mem mem in
down_up_identity_aux heap (ptrs_of_mem mem) [] mem | val down_up_identity (mem:interop_heap)
: Lemma (mem == up_mem (down_mem mem) mem)
let down_up_identity mem = | false | null | true | let heap = down_mem mem in
down_up_identity_aux heap (ptrs_of_mem mem) [] mem | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.down_up_identity_aux",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Prims.Nil",
"Vale.Interop.Types.b8",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.correct_down",
"Vale.Interop.down_mem",
"Prims.unit"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)})
: Lemma (m == up_mem_aux h ps accu m) =
match ps with
| [] -> ()
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
(* The previous assertion and lemma ensure that m == m' *)
down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val down_up_identity (mem:interop_heap)
: Lemma (mem == up_mem (down_mem mem) mem) | [] | Vale.Interop.down_up_identity | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | mem: Vale.Interop.Heap_s.interop_heap
-> FStar.Pervasives.Lemma (ensures mem == Vale.Interop.up_mem (Vale.Interop.down_mem mem) mem) | {
"end_col": 52,
"end_line": 404,
"start_col": 26,
"start_line": 402
} |
FStar.Pervasives.Lemma | val same_unspecified_down
(hs1: HS.mem)
(hs2: HS.mem)
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs})
: Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
forall i. not (valid_addr mem1 i) ==> // REVIEW: the 'forall' lacks a {:pattern ...}
heap1.[i] == heap2.[i]) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) | val same_unspecified_down
(hs1: HS.mem)
(hs2: HS.mem)
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs})
: Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
forall i. not (valid_addr mem1 i) ==> // REVIEW: the 'forall' lacks a {:pattern ...}
heap1.[i] == heap2.[i])
let same_unspecified_down hs1 hs2 ptrs = | false | null | true | Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.list",
"Vale.Interop.Types.b8",
"Prims.l_and",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.list_live",
"FStar.Classical.forall_intro",
"Prims.int",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_Negation",
"Vale.Interop.valid_addr",
"Vale.Interop.Heap_s.mem_of_hs_roots",
"Prims.eq2",
"Vale.Def.Types_s.nat8",
"Vale.Interop.op_String_Access",
"Vale.Interop.down_mem",
"Vale.Interop.same_unspecified_down_aux",
"Prims.unit"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_unspecified_down
(hs1: HS.mem)
(hs2: HS.mem)
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs})
: Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
forall i. not (valid_addr mem1 i) ==> // REVIEW: the 'forall' lacks a {:pattern ...}
heap1.[i] == heap2.[i]) | [] | Vale.Interop.same_unspecified_down | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
hs1: FStar.Monotonic.HyperStack.mem ->
hs2: FStar.Monotonic.HyperStack.mem ->
ptrs:
Prims.list Vale.Interop.Types.b8
{ Vale.Interop.Heap_s.list_disjoint_or_eq ptrs /\ Vale.Interop.Heap_s.list_live hs1 ptrs /\
Vale.Interop.Heap_s.list_live hs2 ptrs }
-> FStar.Pervasives.Lemma
(ensures
(let mem1 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs1 in
let mem2 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs2 in
let addrs = Vale.Interop.Heap_s.addrs_of_mem mem1 in
let heap1 = Vale.Interop.down_mem mem1 in
let heap2 = Vale.Interop.down_mem mem2 in
forall (i: Prims.int).
Prims.op_Negation (Vale.Interop.valid_addr mem1 i) ==> heap1.[ i ] == heap2.[ i ])) | {
"end_col": 65,
"end_line": 349,
"start_col": 2,
"start_line": 349
} |
Prims.Tot | val down_mem: down_mem_t | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f | val down_mem: down_mem_t
let down_mem mem = | false | null | false | let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x: int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in
Classical.forall_intro aux;
heap_f | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"total"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.int",
"Prims.l_iff",
"Prims.b2t",
"FStar.Set.mem",
"Vale.Interop.Heap_s.addrs_set",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Prims.l_True",
"Prims.squash",
"Vale.Def.Words_s.nat8",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Interop.lemma_down_mem_aux_domain",
"Vale.Interop.Types.b8",
"Vale.Interop.addrs_set_lemma_all",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Heap_s.correct_down_p",
"Vale.Interop.down_mem_aux",
"Prims.list",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.ptrs_of_mem",
"FStar.Map.t",
"FStar.Map.restrict",
"FStar.Set.empty",
"FStar.Map.const",
"Vale.Interop.Heap_s.correct_down"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x | false | true | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val down_mem: down_mem_t | [] | Vale.Interop.down_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Interop.Heap_s.down_mem_t | {
"end_col": 8,
"end_line": 293,
"start_col": 18,
"start_line": 283
} |
FStar.Pervasives.Lemma | val up_down_identity
(mem:interop_heap)
(heap:machine_heap{Set.equal (addrs_set mem) (Map.domain heap)})
: Lemma
(requires
(forall x.{:pattern Map.sel heap x \/ Map.sel (down_mem mem) x}
not (Map.contains heap x) ==> Map.sel heap x == Map.sel (down_mem mem) x))
(ensures (down_mem (up_mem heap mem) == heap)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let up_down_identity mem heap =
let new_heap = down_mem (up_mem heap mem) in
same_unspecified_down (hs_of_mem mem) (hs_of_mem (up_mem heap mem)) (ptrs_of_mem mem);
let aux (x:int) : Lemma
(requires Map.contains heap x)
(ensures Map.sel heap x == Map.sel new_heap x) =
up_down_identity_aux (up_mem heap mem) heap x
in Classical.forall_intro (Classical.move_requires aux);
assert (Map.equal heap new_heap) | val up_down_identity
(mem:interop_heap)
(heap:machine_heap{Set.equal (addrs_set mem) (Map.domain heap)})
: Lemma
(requires
(forall x.{:pattern Map.sel heap x \/ Map.sel (down_mem mem) x}
not (Map.contains heap x) ==> Map.sel heap x == Map.sel (down_mem mem) x))
(ensures (down_mem (up_mem heap mem) == heap))
let up_down_identity mem heap = | false | null | true | let new_heap = down_mem (up_mem heap mem) in
same_unspecified_down (hs_of_mem mem) (hs_of_mem (up_mem heap mem)) (ptrs_of_mem mem);
let aux (x: int)
: Lemma (requires Map.contains heap x) (ensures Map.sel heap x == Map.sel new_heap x) =
up_down_identity_aux (up_mem heap mem) heap x
in
Classical.forall_intro (Classical.move_requires aux);
assert (Map.equal heap new_heap) | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Arch.MachineHeap_s.machine_heap",
"FStar.Set.equal",
"Prims.int",
"Vale.Interop.Heap_s.addrs_set",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Prims._assert",
"FStar.Map.equal",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"Prims.b2t",
"FStar.Map.contains",
"Prims.eq2",
"FStar.Map.sel",
"FStar.Classical.move_requires",
"Vale.Def.Words_s.nat8",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Interop.up_down_identity_aux",
"Vale.Interop.up_mem",
"Vale.Interop.same_unspecified_down",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Vale.Interop.Heap_s.correct_down",
"Vale.Interop.down_mem"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)})
: Lemma (m == up_mem_aux h ps accu m) =
match ps with
| [] -> ()
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
(* The previous assertion and lemma ensure that m == m' *)
down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let down_up_identity mem =
let heap = down_mem mem in
down_up_identity_aux heap (ptrs_of_mem mem) [] mem
// Selecting a buffer index in any corresponding map of bytes always yields the same result
let correct_down_p_same_sel
(mem:interop_heap)
(heap1 heap2:machine_heap)
(x:int)
(b:b8) : Lemma
(requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)
/\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) =
let addrs = addrs_of_mem mem in
let i = x - addrs b in
assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i));
assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i))
let up_down_identity_aux
(mem:interop_heap)
(init_heap:machine_heap{correct_down mem init_heap})
(x:int) : Lemma
(requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x) =
let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
addrs_set_lemma_all ();
Classical.forall_intro
(Classical.move_requires
(correct_down_p_same_sel mem (down_mem mem) init_heap x)
) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val up_down_identity
(mem:interop_heap)
(heap:machine_heap{Set.equal (addrs_set mem) (Map.domain heap)})
: Lemma
(requires
(forall x.{:pattern Map.sel heap x \/ Map.sel (down_mem mem) x}
not (Map.contains heap x) ==> Map.sel heap x == Map.sel (down_mem mem) x))
(ensures (down_mem (up_mem heap mem) == heap)) | [] | Vale.Interop.up_down_identity | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Interop.Heap_s.interop_heap ->
heap:
Vale.Arch.MachineHeap_s.machine_heap
{FStar.Set.equal (Vale.Interop.Heap_s.addrs_set mem) (FStar.Map.domain heap)}
-> FStar.Pervasives.Lemma
(requires
forall (x: Prims.int).
{:pattern FStar.Map.sel heap x\/FStar.Map.sel (Vale.Interop.down_mem mem) x}
Prims.op_Negation (FStar.Map.contains heap x) ==>
FStar.Map.sel heap x == FStar.Map.sel (Vale.Interop.down_mem mem) x)
(ensures Vale.Interop.down_mem (Vale.Interop.up_mem heap mem) == heap) | {
"end_col": 34,
"end_line": 442,
"start_col": 31,
"start_line": 434
} |
FStar.Pervasives.Lemma | val lemma_write_buffer_domain (a: b8) (heap: machine_heap) (mem: interop_heap)
: Lemma
(Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap | val lemma_write_buffer_domain (a: b8) (heap: machine_heap) (mem: interop_heap)
: Lemma
(Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem)))
let lemma_write_buffer_domain (a: b8) (heap: machine_heap) (mem: interop_heap)
: Lemma
(Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) = | false | null | true | let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Types.b8",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.monotone_domain_write_vale_mem",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.int",
"Prims.l_iff",
"Prims.b2t",
"FStar.Set.mem",
"Vale.Interop.Heap_s.addrs_ptr",
"Vale.Interop.Heap_s.addrs_of_mem",
"FStar.Set.empty",
"Prims.l_or",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.op_LessThan",
"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",
"Vale.Interop.addrs_ptr_lemma",
"Vale.Interop.domain2_write_vale_mem",
"Vale.Interop.domain_write_vale_mem",
"Vale.Def.Words_s.nat64",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"Prims.nat",
"LowStar.BufferView.Down.buffer",
"FStar.Set.set",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Vale.Interop.write_buffer_vale",
"Prims.l_True",
"Prims.squash",
"FStar.Set.equal",
"FStar.Set.union",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_write_buffer_domain (a: b8) (heap: machine_heap) (mem: interop_heap)
: Lemma
(Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) | [] | Vale.Interop.lemma_write_buffer_domain | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Vale.Interop.Types.b8 ->
heap: Vale.Arch.MachineHeap_s.machine_heap ->
mem: Vale.Interop.Heap_s.interop_heap
-> FStar.Pervasives.Lemma
(ensures
FStar.Set.equal (FStar.Set.union (FStar.Map.domain heap)
(Vale.Interop.Heap_s.addrs_ptr 0
(Vale.Interop.Heap_s.addrs_of_mem mem)
a
FStar.Set.empty))
(FStar.Map.domain (Vale.Interop.write_buffer_vale a heap mem))) | {
"end_col": 61,
"end_line": 250,
"start_col": 51,
"start_line": 238
} |
FStar.Pervasives.Lemma | val update_buffer_up_mem
(mem:interop_heap)
(b:b8{List.memP b (ptrs_of_mem mem)})
(heap1:machine_heap{correct_down mem heap1})
(heap2:machine_heap{Set.equal (Map.domain heap1) (Map.domain heap2)})
: Lemma
(requires
(forall x.{:pattern heap1.[x] \/ heap2.[x]}
x < addrs_of_mem mem b \/ x >= addrs_of_mem mem b + DV.length (get_downview b.bsrc)
==> heap1.[x] == heap2.[x]))
(ensures hs_of_mem (up_mem heap2 mem) ==
DV.upd_seq (hs_of_mem mem) (get_downview b.bsrc) (get_seq_heap heap2 (addrs_of_mem mem) b)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_buffer_up_mem m b h1 h2 =
let ptrs = ptrs_of_mem m in
update_buffer_up_mem_aux h1 h2 ptrs [] b m | val update_buffer_up_mem
(mem:interop_heap)
(b:b8{List.memP b (ptrs_of_mem mem)})
(heap1:machine_heap{correct_down mem heap1})
(heap2:machine_heap{Set.equal (Map.domain heap1) (Map.domain heap2)})
: Lemma
(requires
(forall x.{:pattern heap1.[x] \/ heap2.[x]}
x < addrs_of_mem mem b \/ x >= addrs_of_mem mem b + DV.length (get_downview b.bsrc)
==> heap1.[x] == heap2.[x]))
(ensures hs_of_mem (up_mem heap2 mem) ==
DV.upd_seq (hs_of_mem mem) (get_downview b.bsrc) (get_seq_heap heap2 (addrs_of_mem mem) b))
let update_buffer_up_mem m b h1 h2 = | false | null | true | let ptrs = ptrs_of_mem m in
update_buffer_up_mem_aux h1 h2 ptrs [] b m | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.Types.b8",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.correct_down",
"FStar.Set.equal",
"Prims.int",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Vale.Interop.update_buffer_up_mem_aux",
"Prims.Nil",
"Prims.list",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Prims.unit"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)})
: Lemma (m == up_mem_aux h ps accu m) =
match ps with
| [] -> ()
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
(* The previous assertion and lemma ensure that m == m' *)
down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let down_up_identity mem =
let heap = down_mem mem in
down_up_identity_aux heap (ptrs_of_mem mem) [] mem
// Selecting a buffer index in any corresponding map of bytes always yields the same result
let correct_down_p_same_sel
(mem:interop_heap)
(heap1 heap2:machine_heap)
(x:int)
(b:b8) : Lemma
(requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)
/\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) =
let addrs = addrs_of_mem mem in
let i = x - addrs b in
assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i));
assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i))
let up_down_identity_aux
(mem:interop_heap)
(init_heap:machine_heap{correct_down mem init_heap})
(x:int) : Lemma
(requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x) =
let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
addrs_set_lemma_all ();
Classical.forall_intro
(Classical.move_requires
(correct_down_p_same_sel mem (down_mem mem) init_heap x)
)
let up_down_identity mem heap =
let new_heap = down_mem (up_mem heap mem) in
same_unspecified_down (hs_of_mem mem) (hs_of_mem (up_mem heap mem)) (ptrs_of_mem mem);
let aux (x:int) : Lemma
(requires Map.contains heap x)
(ensures Map.sel heap x == Map.sel new_heap x) =
up_down_identity_aux (up_mem heap mem) heap x
in Classical.forall_intro (Classical.move_requires aux);
assert (Map.equal heap new_heap)
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 1 --initial_fuel 1 --initial_ifuel 1"
let rec update_buffer_up_mem_aux
(h1 h2:machine_heap)
(ps:list b8)
(accu:list b8)
(b:b8)
(m:interop_heap{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu}) : Lemma
(requires
List.memP b (ptrs_of_mem m) /\
Set.equal (Map.domain h1) (addrs_set m) /\
Set.equal (Map.domain h2) (addrs_set m) /\
(forall p. List.memP p accu ==> correct_down_p m h2 p) /\
(List.memP b accu ==> DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\
(forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\
(forall x. x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==>
h1.[x] == h2.[x])
)
(ensures
(List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\
(~(List.memP b accu) ==> hs_of_mem (up_mem_aux h2 ps accu m) ==
DV.upd_seq (hs_of_mem m) (get_downview b.bsrc) (get_seq_heap h2 (addrs_of_mem m) b))) =
match ps with
| [] -> ()
| hd::tl ->
let db = get_downview hd.bsrc in
let addrs = addrs_of_mem m in
let mem = hs_of_mem m in
let ptrs = ptrs_of_mem m in
let s = get_seq_heap h2 addrs hd in
DV.upd_seq_spec mem db s;
let m' = DV.upd_seq mem db s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
let aux2 () : Lemma
(requires hd =!= b)
(ensures DV.as_seq mem db == get_seq_heap h2 addrs hd) =
reveal_opaque (`%addr_map_pred) addr_map_pred;
get_seq_heap_as_seq h1 h2 m hd
in Classical.move_requires aux2 ();
update_buffer_up_mem_aux h1 h2 tl (hd::accu) b (InteropHeap ptrs addrs m') | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_buffer_up_mem
(mem:interop_heap)
(b:b8{List.memP b (ptrs_of_mem mem)})
(heap1:machine_heap{correct_down mem heap1})
(heap2:machine_heap{Set.equal (Map.domain heap1) (Map.domain heap2)})
: Lemma
(requires
(forall x.{:pattern heap1.[x] \/ heap2.[x]}
x < addrs_of_mem mem b \/ x >= addrs_of_mem mem b + DV.length (get_downview b.bsrc)
==> heap1.[x] == heap2.[x]))
(ensures hs_of_mem (up_mem heap2 mem) ==
DV.upd_seq (hs_of_mem mem) (get_downview b.bsrc) (get_seq_heap heap2 (addrs_of_mem mem) b)) | [] | Vale.Interop.update_buffer_up_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Interop.Heap_s.interop_heap ->
b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b (Vale.Interop.Heap_s.ptrs_of_mem mem)} ->
heap1: Vale.Arch.MachineHeap_s.machine_heap{Vale.Interop.Heap_s.correct_down mem heap1} ->
heap2:
Vale.Arch.MachineHeap_s.machine_heap
{FStar.Set.equal (FStar.Map.domain heap1) (FStar.Map.domain heap2)}
-> FStar.Pervasives.Lemma
(requires
forall (x: Prims.int). {:pattern heap1.[ x ]\/heap2.[ x ]}
x < Vale.Interop.Heap_s.addrs_of_mem mem b \/
x >=
Vale.Interop.Heap_s.addrs_of_mem mem b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==>
heap1.[ x ] == heap2.[ x ])
(ensures
Vale.Interop.Heap_s.hs_of_mem (Vale.Interop.up_mem heap2 mem) ==
LowStar.BufferView.Down.upd_seq (Vale.Interop.Heap_s.hs_of_mem mem)
(Vale.Interop.Types.get_downview (Buffer?.bsrc b))
(Vale.Interop.get_seq_heap heap2 (Vale.Interop.Heap_s.addrs_of_mem mem) b)) | {
"end_col": 44,
"end_line": 493,
"start_col": 36,
"start_line": 491
} |
Prims.Tot | val write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Tot machine_heap (decreases (length - i)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
) | val write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Tot machine_heap (decreases (length - i))
let rec write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
addr
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Tot machine_heap (decreases (length - i)) = | false | null | false | if i >= length
then curr_heap
else
(let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i + 1) heap) | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"total",
""
] | [
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.eq2",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Vale.Def.Words_s.pow2_8",
"Vale.Interop.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Prims.bool",
"Vale.Interop.write_vale_mem",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Interop.op_String_Assignment"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Tot machine_heap (decreases (length - i)) | [
"recursion"
] | Vale.Interop.write_vale_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
contents: FStar.Seq.Base.seq FStar.UInt8.t ->
length: Prims.nat{length = FStar.Seq.Base.length contents} ->
addr: Prims.int ->
i: Prims.nat{i <= length} ->
curr_heap:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}).
{:pattern FStar.Seq.Base.index contents j}
0 <= j /\ j < i ==>
curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) }
-> Prims.Tot Vale.Arch.MachineHeap_s.machine_heap | {
"end_col": 3,
"end_line": 27,
"start_col": 2,
"start_line": 23
} |
FStar.Pervasives.Lemma | val frame_down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
(i: int)
: Lemma
(requires
(forall (b: b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[ i ] == (down_mem_aux ptrs mem ps accu h).[ i ]) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i | val frame_down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
(i: int)
: Lemma
(requires
(forall (b: b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[ i ] == (down_mem_aux ptrs mem ps accu h).[ i ])
let rec frame_down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
(i: int)
: Lemma
(requires
(forall (b: b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[ i ] == (down_mem_aux ptrs mem ps accu h).[ i ]) = | false | null | true | match ps with
| [] -> ()
| a :: q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a :: accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Prims.list",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.interop_heap",
"Prims.l_Forall",
"Prims.l_iff",
"FStar.List.Tot.Base.memP",
"Prims.l_or",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_imp",
"Vale.Interop.Heap_s.correct_down_p",
"Prims.int",
"Vale.Interop.frame_write_vale_mem",
"Prims.unit",
"Vale.Interop.frame_down_mem_aux",
"Prims.Cons",
"Vale.Interop.Heap_s.list_disjoint_or_eq_reveal",
"Vale.Interop.correct_down_p_frame",
"Vale.Interop.correct_down_p_cancel",
"Vale.Interop.load_store_write_vale_mem",
"Vale.Def.Words_s.nat64",
"Vale.Interop.Heap_s.addrs_of_mem",
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.length",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"Prims.nat",
"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",
"Vale.Interop.write_buffer_vale",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"Prims.squash",
"Prims.eq2",
"Vale.Def.Types_s.nat8",
"Vale.Interop.op_String_Access",
"Vale.Interop.down_mem_aux",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc))) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frame_down_mem_aux
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p})
(i: int)
: Lemma
(requires
(forall (b: b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[ i ] == (down_mem_aux ptrs mem ps accu h).[ i ]) | [
"recursion"
] | Vale.Interop.frame_down_mem_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
ptrs: Prims.list Vale.Interop.Types.b8 {Vale.Interop.Heap_s.list_disjoint_or_eq ptrs} ->
mem: Vale.Interop.Heap_s.interop_heap ->
ps: Prims.list Vale.Interop.Types.b8 ->
accu:
Prims.list Vale.Interop.Types.b8
{ forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p ptrs <==>
FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu } ->
h:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (p: Vale.Interop.Types.b8). {:pattern FStar.List.Tot.Base.memP p accu}
FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p mem h p } ->
i: Prims.int
-> FStar.Pervasives.Lemma
(requires
forall (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ps}).
let base = Vale.Interop.Heap_s.addrs_of_mem mem b in
i < base \/
i >=
base + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)))
(ensures h.[ i ] == (Vale.Interop.down_mem_aux ptrs mem ps accu h).[ i ]) | {
"end_col": 51,
"end_line": 320,
"start_col": 2,
"start_line": 307
} |
FStar.Pervasives.Lemma | val addrs_set_lemma_aux (addrs: addr_map) (ptrs: list b8) (acc: Set.set int) (x: int)
: Lemma (requires True)
(ensures
Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b: b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x | val addrs_set_lemma_aux (addrs: addr_map) (ptrs: list b8) (acc: Set.set int) (x: int)
: Lemma (requires True)
(ensures
Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b: b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc))
let rec addrs_set_lemma_aux (addrs: addr_map) (ptrs: list b8) (acc: Set.set int) (x: int)
: Lemma (requires True)
(ensures
Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b: b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = | false | null | true | match ptrs with
| [] -> ()
| a :: q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Types.addr_map",
"Prims.list",
"Vale.Interop.Types.b8",
"FStar.Set.set",
"Prims.int",
"Vale.Interop.addrs_set_lemma_aux",
"Prims.unit",
"Vale.Interop.addrs_ptr_lemma",
"FStar.List.Tot.Base.fold_right_gtot",
"Vale.Interop.Heap_s.addrs_ptr",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"Prims.b2t",
"FStar.Set.mem",
"Prims.l_or",
"Prims.l_Exists",
"FStar.List.Tot.Base.memP",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"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.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}). | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addrs_set_lemma_aux (addrs: addr_map) (ptrs: list b8) (acc: Set.set int) (x: int)
: Lemma (requires True)
(ensures
Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b: b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) | [
"recursion"
] | Vale.Interop.addrs_set_lemma_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
addrs: Vale.Interop.Types.addr_map ->
ptrs: Prims.list Vale.Interop.Types.b8 ->
acc: FStar.Set.set Prims.int ->
x: Prims.int
-> FStar.Pervasives.Lemma
(ensures
FStar.Set.mem x
(FStar.List.Tot.Base.fold_right_gtot ptrs (Vale.Interop.Heap_s.addrs_ptr 0 addrs) acc) <==>
(exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}).
addrs b <= x /\
x <
addrs b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b))) \/
FStar.Set.mem x acc) | {
"end_col": 37,
"end_line": 194,
"start_col": 2,
"start_line": 189
} |
FStar.Pervasives.Lemma | val frame_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
(j: int)
: Lemma (requires j < addr \/ j >= addr + length)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[ j ] == new_heap.[ j ]))
(decreases (length - i)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
) | val frame_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
(j: int)
: Lemma (requires j < addr \/ j >= addr + length)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[ j ] == new_heap.[ j ]))
(decreases (length - i))
let rec frame_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
addr
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
(j: int)
: Lemma (requires j < addr \/ j >= addr + length)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[ j ] == new_heap.[ j ]))
(decreases (length - i)) = | false | null | true | if i >= length
then ()
else
(let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i + 1) heap j) | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma",
""
] | [
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.eq2",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Vale.Def.Words_s.pow2_8",
"Vale.Interop.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Prims.bool",
"Vale.Interop.frame_write_vale_mem",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Interop.op_String_Assignment",
"Prims.unit",
"Prims.squash",
"Vale.Interop.write_vale_mem",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j])) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frame_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
(j: int)
: Lemma (requires j < addr \/ j >= addr + length)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[ j ] == new_heap.[ j ]))
(decreases (length - i)) | [
"recursion"
] | Vale.Interop.frame_write_vale_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
contents: FStar.Seq.Base.seq FStar.UInt8.t ->
length: Prims.nat{length = FStar.Seq.Base.length contents} ->
addr: Prims.int ->
i: Prims.nat{i <= length} ->
curr_heap:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}).
{:pattern FStar.Seq.Base.index contents j}
0 <= j /\ j < i ==>
curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) } ->
j: Prims.int
-> FStar.Pervasives.Lemma (requires j < addr \/ j >= addr + length)
(ensures
(let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in
curr_heap.[ j ] == new_heap.[ j ]))
(decreases length - i) | {
"end_col": 5,
"end_line": 45,
"start_col": 4,
"start_line": 41
} |
FStar.Pervasives.Lemma | val correct_down_p_cancel (mem: interop_heap) (heap: _) (p: b8)
: Lemma
(forall p'.
p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux | val correct_down_p_cancel (mem: interop_heap) (heap: _) (p: b8)
: Lemma
(forall p'.
p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p'))
let correct_down_p_cancel (mem: interop_heap) heap (p: b8)
: Lemma
(forall p'.
p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) = | false | null | true | let rec aux (p': b8)
: Lemma
(p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Types.b8",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"Prims.eq2",
"Vale.Interop.Heap_s.correct_down_p",
"Vale.Interop.write_vale_mem",
"LowStar.BufferView.Down.as_seq",
"FStar.UInt8.t",
"Vale.Interop.Heap_s.hs_of_mem",
"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",
"LowStar.BufferView.Down.length",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Vale.Def.Words_s.nat64",
"FStar.Seq.Properties.lseq",
"Prims.nat",
"LowStar.BufferView.Down.buffer",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Interop.load_store_write_vale_mem",
"Prims.l_Forall"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val correct_down_p_cancel (mem: interop_heap) (heap: _) (p: b8)
: Lemma
(forall p'.
p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) | [] | Vale.Interop.correct_down_p_cancel | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Interop.Heap_s.interop_heap ->
heap: Vale.Arch.MachineHeap_s.machine_heap ->
p: Vale.Interop.Types.b8
-> FStar.Pervasives.Lemma
(ensures
forall (p': Vale.Interop.Types.b8).
p == p' ==>
(let b = Vale.Interop.Types.get_downview (Buffer?.bsrc p) in
let length = LowStar.BufferView.Down.length b in
let contents = LowStar.BufferView.Down.as_seq (Vale.Interop.Heap_s.hs_of_mem mem) b in
let addr = Vale.Interop.Heap_s.addrs_of_mem mem p in
let new_heap = Vale.Interop.write_vale_mem contents length addr 0 heap in
Vale.Interop.Heap_s.correct_down_p mem new_heap p')) | {
"end_col": 28,
"end_line": 143,
"start_col": 40,
"start_line": 127
} |
FStar.Pervasives.Lemma | val domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j.
Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end | val domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j.
Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))
let rec domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
addr
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j.
Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i)) = | false | null | true | if i >= length
then ()
else
let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i + 1) heap | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma",
""
] | [
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.eq2",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Vale.Def.Words_s.pow2_8",
"Vale.Interop.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Prims.bool",
"Vale.Interop.domain_write_vale_mem",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Interop.op_String_Assignment",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"FStar.Set.mem",
"FStar.Map.domain",
"Prims.op_Negation",
"Vale.Interop.write_vale_mem",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length)) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j.
Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i)) | [
"recursion"
] | Vale.Interop.domain_write_vale_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
contents: FStar.Seq.Base.seq FStar.UInt8.t ->
length: Prims.nat{length = FStar.Seq.Base.length contents} ->
addr: Prims.int ->
i: Prims.nat{i <= length} ->
curr_heap:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}).
{:pattern FStar.Seq.Base.index contents j}
0 <= j /\ j < i ==>
curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) }
-> FStar.Pervasives.Lemma
(ensures
(let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in
forall (j: Prims.int).
FStar.Set.mem j (FStar.Map.domain new_heap) /\
Prims.op_Negation (FStar.Set.mem j (FStar.Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length)) (decreases length - i) | {
"end_col": 7,
"end_line": 82,
"start_col": 3,
"start_line": 78
} |
FStar.Pervasives.Lemma | val correct_down_p_frame (mem: interop_heap) (heap: machine_heap) (p: b8)
: Lemma
(forall p'.
disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux | val correct_down_p_frame (mem: interop_heap) (heap: machine_heap) (p: b8)
: Lemma
(forall p'.
disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p'))
let correct_down_p_frame (mem: interop_heap) (heap: machine_heap) (p: b8)
: Lemma
(forall p'.
disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) = | false | null | true | let rec aux (p': b8)
: Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)
)
in
Classical.forall_intro aux | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Types.b8",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"Prims.l_and",
"Vale.Interop.disjoint",
"Vale.Interop.Heap_s.correct_down_p",
"Vale.Interop.write_vale_mem",
"LowStar.BufferView.Down.as_seq",
"FStar.UInt8.t",
"Vale.Interop.Heap_s.hs_of_mem",
"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",
"LowStar.BufferView.Down.length",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Vale.Def.Words_s.nat64",
"FStar.Seq.Properties.lseq",
"Prims.nat",
"LowStar.BufferView.Down.buffer",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"Prims.eq2",
"Vale.Def.Types_s.nat8",
"Vale.Interop.op_String_Access",
"FStar.Classical.move_requires",
"Vale.Interop.frame_write_vale_mem",
"FStar.Pervasives.reveal_opaque",
"Prims.logical",
"Vale.Interop.Types.addr_map_pred",
"Prims.l_Forall"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val correct_down_p_frame (mem: interop_heap) (heap: machine_heap) (p: b8)
: Lemma
(forall p'.
disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) | [] | Vale.Interop.correct_down_p_frame | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Interop.Heap_s.interop_heap ->
heap: Vale.Arch.MachineHeap_s.machine_heap ->
p: Vale.Interop.Types.b8
-> FStar.Pervasives.Lemma
(ensures
forall (p': Vale.Interop.Types.b8).
Vale.Interop.disjoint p p' /\ Vale.Interop.Heap_s.correct_down_p mem heap p' ==>
(let b = Vale.Interop.Types.get_downview (Buffer?.bsrc p) in
let length = LowStar.BufferView.Down.length b in
let contents = LowStar.BufferView.Down.as_seq (Vale.Interop.Heap_s.hs_of_mem mem) b in
let addr = Vale.Interop.Heap_s.addrs_of_mem mem p in
let new_heap = Vale.Interop.write_vale_mem contents length addr 0 heap in
Vale.Interop.Heap_s.correct_down_p mem new_heap p')) | {
"end_col": 28,
"end_line": 169,
"start_col": 40,
"start_line": 152
} |
FStar.Pervasives.Lemma | val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i]) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i | val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i = | false | null | true | addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.list",
"Vale.Interop.Types.b8",
"Prims.l_and",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.list_live",
"Prims.int",
"FStar.Classical.move_requires",
"Prims.l_Forall",
"FStar.List.Tot.Base.memP",
"Prims.l_or",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"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.eq2",
"Vale.Def.Types_s.nat8",
"Vale.Interop.op_String_Access",
"Vale.Interop.down_mem_aux",
"Prims.Nil",
"Vale.Interop.frame_down_mem_aux",
"Prims.unit",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_imp",
"Vale.Interop.Heap_s.correct_down_p",
"Vale.Interop.Types.addr_map",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.Heap_s.mem_of_hs_roots",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"FStar.Map.restrict",
"FStar.Set.empty",
"FStar.Map.const",
"Vale.Interop.addrs_set_lemma_all"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i]) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i]) | [] | Vale.Interop.same_unspecified_down_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
hs1: FStar.Monotonic.HyperStack.mem ->
hs2: FStar.Monotonic.HyperStack.mem ->
ptrs:
Prims.list Vale.Interop.Types.b8
{ Vale.Interop.Heap_s.list_disjoint_or_eq ptrs /\ Vale.Interop.Heap_s.list_live hs1 ptrs /\
Vale.Interop.Heap_s.list_live hs2 ptrs } ->
i: Prims.int
-> FStar.Pervasives.Lemma
(ensures
(let mem1 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs1 in
let mem2 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs2 in
let addrs = Vale.Interop.Heap_s.addrs_of_mem mem1 in
let heap1 = Vale.Interop.down_mem mem1 in
let heap2 = Vale.Interop.down_mem mem2 in
Prims.op_Negation (Vale.Interop.valid_addr mem1 i) ==> heap1.[ i ] == heap2.[ i ])) | {
"end_col": 71,
"end_line": 346,
"start_col": 2,
"start_line": 337
} |
FStar.Pervasives.Lemma | val domain2_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end | val domain2_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))
let rec domain2_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
addr
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i)) = | false | null | true | if i >= length
then ()
else
let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i + 1) heap | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma",
""
] | [
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.eq2",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Vale.Def.Words_s.pow2_8",
"Vale.Interop.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Prims.bool",
"Vale.Interop.domain2_write_vale_mem",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Interop.op_String_Assignment",
"Prims.unit",
"FStar.Set.mem",
"FStar.Map.domain",
"Prims.squash",
"Vale.Interop.write_vale_mem",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val domain2_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i)) | [
"recursion"
] | Vale.Interop.domain2_write_vale_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
contents: FStar.Seq.Base.seq FStar.UInt8.t ->
length: Prims.nat{length = FStar.Seq.Base.length contents} ->
addr: Prims.int ->
i: Prims.nat{i <= length} ->
curr_heap:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}).
{:pattern FStar.Seq.Base.index contents j}
0 <= j /\ j < i ==>
curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) }
-> FStar.Pervasives.Lemma
(requires
forall (j: Prims.int).
addr <= j /\ j < addr + i ==> FStar.Set.mem j (FStar.Map.domain curr_heap))
(ensures
(let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in
forall (j: Prims.int).
addr <= j /\ j < addr + length ==> FStar.Set.mem j (FStar.Map.domain new_heap)))
(decreases length - i) | {
"end_col": 7,
"end_line": 99,
"start_col": 3,
"start_line": 95
} |
FStar.Pervasives.Lemma | val monotone_domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end | val monotone_domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))
let rec monotone_domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
addr
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i)) = | false | null | true | if i >= length
then ()
else
let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i + 1) heap | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma",
""
] | [
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.eq2",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Vale.Def.Words_s.pow2_8",
"Vale.Interop.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Prims.bool",
"Vale.Interop.monotone_domain_write_vale_mem",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Interop.op_String_Assignment",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"FStar.Set.mem",
"FStar.Map.domain",
"Vale.Interop.write_vale_mem",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val monotone_domain_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i)) | [
"recursion"
] | Vale.Interop.monotone_domain_write_vale_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
contents: FStar.Seq.Base.seq FStar.UInt8.t ->
length: Prims.nat{length = FStar.Seq.Base.length contents} ->
addr: Prims.int ->
i: Prims.nat{i <= length} ->
curr_heap:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}).
{:pattern FStar.Seq.Base.index contents j}
0 <= j /\ j < i ==>
curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) }
-> FStar.Pervasives.Lemma
(ensures
(let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in
forall (j: Prims.int).
FStar.Set.mem j (FStar.Map.domain curr_heap) ==>
FStar.Set.mem j (FStar.Map.domain new_heap))) (decreases length - i) | {
"end_col": 7,
"end_line": 116,
"start_col": 3,
"start_line": 112
} |
Prims.GTot | val up_mem_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: GTot (m': interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') | val up_mem_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: GTot (m': interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h})
let rec up_mem_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: GTot (m': interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = | false | null | false | match ps with
| [] -> m
| hd :: tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p: b8)
: Lemma
(requires
MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)
) =
lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in
Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd :: accu) (InteropHeap m.ptrs m.addrs m') | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.list",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.interop_heap",
"Prims.l_and",
"FStar.Set.equal",
"Prims.int",
"Vale.Interop.Heap_s.addrs_set",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Heap_s.correct_down_p",
"Prims.l_iff",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Prims.l_or",
"Vale.Interop.up_mem_aux",
"Prims.Cons",
"Vale.Interop.Heap_s.InteropHeap",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"Prims.unit",
"Vale.Interop.Heap_s.list_disjoint_or_eq_reveal",
"FStar.Classical.forall_intro",
"LowStar.Monotonic.Buffer.live",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.length",
"Vale.Interop.Types.get_downview",
"LowStar.BufferView.Down.as_seq",
"FStar.Classical.move_requires",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Lib.BufferViewHelpers.lemma_dv_equal",
"Vale.Interop.Types.down_view",
"FStar.Monotonic.HyperStack.mem",
"LowStar.BufferView.Down.upd_seq",
"LowStar.BufferView.Down.upd_seq_spec",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.get_seq_heap",
"Vale.Interop.Heap_s.addrs_of_mem",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.correct_down"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val up_mem_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: GTot (m': interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) | [
"recursion"
] | Vale.Interop.up_mem_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: Vale.Arch.MachineHeap_s.machine_heap ->
ps: Prims.list Vale.Interop.Types.b8 ->
accu: Prims.list Vale.Interop.Types.b8 ->
m:
Vale.Interop.Heap_s.interop_heap
{ FStar.Set.equal (Vale.Interop.Heap_s.addrs_set m) (FStar.Map.domain h) /\
(forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p m h p) /\
(forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p (Vale.Interop.Heap_s.ptrs_of_mem m) <==>
FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu) }
-> Prims.GTot
(m':
Vale.Interop.Heap_s.interop_heap
{ Vale.Interop.Heap_s.ptrs_of_mem m == Vale.Interop.Heap_s.ptrs_of_mem m' /\
Vale.Interop.Heap_s.correct_down m' h }) | {
"end_col": 62,
"end_line": 380,
"start_col": 2,
"start_line": 366
} |
FStar.Pervasives.Lemma | val down_up_identity_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: Lemma (m == up_mem_aux h ps accu m) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)})
: Lemma (m == up_mem_aux h ps accu m) =
match ps with
| [] -> ()
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
(* The previous assertion and lemma ensure that m == m' *)
down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') | val down_up_identity_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: Lemma (m == up_mem_aux h ps accu m)
let rec down_up_identity_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: Lemma (m == up_mem_aux h ps accu m) = | false | null | true | match ps with
| [] -> ()
| hd :: tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
down_up_identity_aux h tl (hd :: accu) (InteropHeap m.ptrs m.addrs m') | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.list",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.interop_heap",
"Prims.l_and",
"Vale.Interop.Heap_s.correct_down",
"Prims.l_Forall",
"Prims.l_iff",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Prims.l_or",
"Vale.Interop.down_up_identity_aux",
"Prims.Cons",
"Vale.Interop.Heap_s.InteropHeap",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.UInt8.t",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"LowStar.BufferView.Down.upd_seq_spec",
"FStar.Monotonic.HyperStack.mem",
"LowStar.BufferView.Down.upd_seq",
"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",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Down.length",
"Vale.Interop.get_seq_heap",
"Vale.Interop.Heap_s.addrs_of_mem",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.up_mem_aux",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val down_up_identity_aux
(h: machine_heap)
(ps accu: list b8)
(m:
interop_heap
{ correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) })
: Lemma (m == up_mem_aux h ps accu m) | [
"recursion"
] | Vale.Interop.down_up_identity_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: Vale.Arch.MachineHeap_s.machine_heap ->
ps: Prims.list Vale.Interop.Types.b8 ->
accu: Prims.list Vale.Interop.Types.b8 ->
m:
Vale.Interop.Heap_s.interop_heap
{ Vale.Interop.Heap_s.correct_down m h /\
(forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p (Vale.Interop.Heap_s.ptrs_of_mem m) <==>
FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu) }
-> FStar.Pervasives.Lemma (ensures m == Vale.Interop.up_mem_aux h ps accu m) | {
"end_col": 72,
"end_line": 400,
"start_col": 2,
"start_line": 391
} |
FStar.Pervasives.Lemma | val load_store_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[ addr + j ]
))
(decreases (length - i)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end | val load_store_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[ addr + j ]
))
(decreases (length - i))
let rec load_store_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
addr
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[ addr + j ]
))
(decreases (length - i)) = | false | null | true | if i >= length
then ()
else
let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i + 1) heap | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma",
""
] | [
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.eq2",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Vale.Def.Words_s.pow2_8",
"Vale.Interop.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Prims.bool",
"Vale.Interop.load_store_write_vale_mem",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Interop.op_String_Assignment",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Vale.Interop.write_vale_mem",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i)) | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_store_write_vale_mem
(contents: Seq.seq UInt8.t)
(length: nat{length = FStar.Seq.Base.length contents})
(addr: _)
(i: nat{i <= length})
(curr_heap:
machine_heap
{ forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) })
: Lemma (requires True)
(ensures
(let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[ addr + j ]
))
(decreases (length - i)) | [
"recursion"
] | Vale.Interop.load_store_write_vale_mem | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
contents: FStar.Seq.Base.seq FStar.UInt8.t ->
length: Prims.nat{length = FStar.Seq.Base.length contents} ->
addr: Prims.int ->
i: Prims.nat{i <= length} ->
curr_heap:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}).
{:pattern FStar.Seq.Base.index contents j}
0 <= j /\ j < i ==>
curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) }
-> FStar.Pervasives.Lemma
(ensures
(let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in
forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}).
0 <= j /\ j < length ==>
FStar.UInt8.v (FStar.Seq.Base.index contents j) == new_heap.[ addr + j ]))
(decreases length - i) | {
"end_col": 5,
"end_line": 64,
"start_col": 2,
"start_line": 60
} |
FStar.Pervasives.Lemma | val lemma_down_mem_aux_domain
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{ forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p })
(x: int)
: Lemma
(requires
Set.mem x (Map.domain h) <==>
(exists (b: b8{List.memP b accu}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)))
(ensures
Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b: b8{List.memP b ptrs}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x | val lemma_down_mem_aux_domain
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{ forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p })
(x: int)
: Lemma
(requires
Set.mem x (Map.domain h) <==>
(exists (b: b8{List.memP b accu}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)))
(ensures
Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b: b8{List.memP b ptrs}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)))
let rec lemma_down_mem_aux_domain
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{ forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p })
(x: int)
: Lemma
(requires
Set.mem x (Map.domain h) <==>
(exists (b: b8{List.memP b accu}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)))
(ensures
Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b: b8{List.memP b ptrs}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))) = | false | null | true | match ps with
| [] -> ()
| a :: tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a :: accu) new_heap x | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Prims.list",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.interop_heap",
"Prims.l_Forall",
"Prims.l_iff",
"FStar.List.Tot.Base.memP",
"Prims.l_or",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.l_imp",
"Vale.Interop.Heap_s.correct_down_p",
"Prims.int",
"Vale.Interop.lemma_down_mem_aux_domain",
"Prims.Cons",
"Prims.unit",
"Vale.Interop.Heap_s.list_disjoint_or_eq_reveal",
"Vale.Interop.correct_down_p_frame",
"Vale.Interop.correct_down_p_cancel",
"Vale.Interop.load_store_write_vale_mem",
"Vale.Def.Words_s.nat64",
"Vale.Interop.Heap_s.addrs_of_mem",
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.length",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"Prims.nat",
"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",
"Vale.Interop.write_buffer_vale",
"Vale.Interop.addrs_ptr_lemma",
"FStar.Set.empty",
"Vale.Interop.lemma_write_buffer_domain",
"Prims.b2t",
"FStar.Set.mem",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Prims.l_Exists",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.squash",
"Vale.Interop.down_mem_aux",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_down_mem_aux_domain
(ptrs: list b8 {list_disjoint_or_eq ptrs})
(mem: interop_heap)
(ps: list b8)
(accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:
machine_heap
{ forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p })
(x: int)
: Lemma
(requires
Set.mem x (Map.domain h) <==>
(exists (b: b8{List.memP b accu}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)))
(ensures
Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b: b8{List.memP b ptrs}). {:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))) | [
"recursion"
] | Vale.Interop.lemma_down_mem_aux_domain | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
ptrs: Prims.list Vale.Interop.Types.b8 {Vale.Interop.Heap_s.list_disjoint_or_eq ptrs} ->
mem: Vale.Interop.Heap_s.interop_heap ->
ps: Prims.list Vale.Interop.Types.b8 ->
accu:
Prims.list Vale.Interop.Types.b8
{ forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p ptrs <==>
FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu } ->
h:
Vale.Arch.MachineHeap_s.machine_heap
{ forall (p: Vale.Interop.Types.b8). {:pattern Vale.Interop.Heap_s.correct_down_p mem h p}
FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p mem h p } ->
x: Prims.int
-> FStar.Pervasives.Lemma
(requires
FStar.Set.mem x (FStar.Map.domain h) <==>
(exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b accu}).
{:pattern Vale.Interop.Heap_s.addrs_of_mem mem b}
Vale.Interop.Heap_s.addrs_of_mem mem b <= x /\
x <
Vale.Interop.Heap_s.addrs_of_mem mem b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b))))
(ensures
FStar.Set.mem x (FStar.Map.domain (Vale.Interop.down_mem_aux ptrs mem ps accu h)) <==>
(exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}).
{:pattern Vale.Interop.Heap_s.addrs_of_mem mem b}
Vale.Interop.Heap_s.addrs_of_mem mem b <= x /\
x <
Vale.Interop.Heap_s.addrs_of_mem mem b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)))) | {
"end_col": 62,
"end_line": 281,
"start_col": 6,
"start_line": 267
} |
FStar.Pervasives.Lemma | val update_buffer_up_mem_aux
(h1 h2: machine_heap)
(ps accu: list b8)
(b: b8)
(m:
interop_heap
{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu})
: Lemma
(requires
List.memP b (ptrs_of_mem m) /\ Set.equal (Map.domain h1) (addrs_set m) /\
Set.equal (Map.domain h2) (addrs_set m) /\
(forall p. List.memP p accu ==> correct_down_p m h2 p) /\
(List.memP b accu ==>
DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\
(forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\
(forall x.
x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==>
h1.[ x ] == h2.[ x ]))
(ensures
(List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\
(~(List.memP b accu) ==>
hs_of_mem (up_mem_aux h2 ps accu m) ==
DV.upd_seq (hs_of_mem m) (get_downview b.bsrc) (get_seq_heap h2 (addrs_of_mem m) b))) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec update_buffer_up_mem_aux
(h1 h2:machine_heap)
(ps:list b8)
(accu:list b8)
(b:b8)
(m:interop_heap{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu}) : Lemma
(requires
List.memP b (ptrs_of_mem m) /\
Set.equal (Map.domain h1) (addrs_set m) /\
Set.equal (Map.domain h2) (addrs_set m) /\
(forall p. List.memP p accu ==> correct_down_p m h2 p) /\
(List.memP b accu ==> DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\
(forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\
(forall x. x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==>
h1.[x] == h2.[x])
)
(ensures
(List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\
(~(List.memP b accu) ==> hs_of_mem (up_mem_aux h2 ps accu m) ==
DV.upd_seq (hs_of_mem m) (get_downview b.bsrc) (get_seq_heap h2 (addrs_of_mem m) b))) =
match ps with
| [] -> ()
| hd::tl ->
let db = get_downview hd.bsrc in
let addrs = addrs_of_mem m in
let mem = hs_of_mem m in
let ptrs = ptrs_of_mem m in
let s = get_seq_heap h2 addrs hd in
DV.upd_seq_spec mem db s;
let m' = DV.upd_seq mem db s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
let aux2 () : Lemma
(requires hd =!= b)
(ensures DV.as_seq mem db == get_seq_heap h2 addrs hd) =
reveal_opaque (`%addr_map_pred) addr_map_pred;
get_seq_heap_as_seq h1 h2 m hd
in Classical.move_requires aux2 ();
update_buffer_up_mem_aux h1 h2 tl (hd::accu) b (InteropHeap ptrs addrs m') | val update_buffer_up_mem_aux
(h1 h2: machine_heap)
(ps accu: list b8)
(b: b8)
(m:
interop_heap
{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu})
: Lemma
(requires
List.memP b (ptrs_of_mem m) /\ Set.equal (Map.domain h1) (addrs_set m) /\
Set.equal (Map.domain h2) (addrs_set m) /\
(forall p. List.memP p accu ==> correct_down_p m h2 p) /\
(List.memP b accu ==>
DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\
(forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\
(forall x.
x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==>
h1.[ x ] == h2.[ x ]))
(ensures
(List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\
(~(List.memP b accu) ==>
hs_of_mem (up_mem_aux h2 ps accu m) ==
DV.upd_seq (hs_of_mem m) (get_downview b.bsrc) (get_seq_heap h2 (addrs_of_mem m) b)))
let rec update_buffer_up_mem_aux
(h1 h2: machine_heap)
(ps accu: list b8)
(b: b8)
(m:
interop_heap
{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu})
: Lemma
(requires
List.memP b (ptrs_of_mem m) /\ Set.equal (Map.domain h1) (addrs_set m) /\
Set.equal (Map.domain h2) (addrs_set m) /\
(forall p. List.memP p accu ==> correct_down_p m h2 p) /\
(List.memP b accu ==>
DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\
(forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\
(forall x.
x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==>
h1.[ x ] == h2.[ x ]))
(ensures
(List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\
(~(List.memP b accu) ==>
hs_of_mem (up_mem_aux h2 ps accu m) ==
DV.upd_seq (hs_of_mem m) (get_downview b.bsrc) (get_seq_heap h2 (addrs_of_mem m) b))) = | false | null | true | match ps with
| [] -> ()
| hd :: tl ->
let db = get_downview hd.bsrc in
let addrs = addrs_of_mem m in
let mem = hs_of_mem m in
let ptrs = ptrs_of_mem m in
let s = get_seq_heap h2 addrs hd in
DV.upd_seq_spec mem db s;
let m' = DV.upd_seq mem db s in
let aux1 (p: b8)
: Lemma
(requires
MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)
) =
lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in
Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
let aux2 () : Lemma (requires hd =!= b) (ensures DV.as_seq mem db == get_seq_heap h2 addrs hd) =
reveal_opaque (`%addr_map_pred) addr_map_pred;
get_seq_heap_as_seq h1 h2 m hd
in
Classical.move_requires aux2 ();
update_buffer_up_mem_aux h1 h2 tl (hd :: accu) b (InteropHeap ptrs addrs m') | {
"checked_file": "Vale.Interop.fst.checked",
"dependencies": [
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Interop.fst"
} | [
"lemma"
] | [
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.list",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.interop_heap",
"Prims.l_Forall",
"Prims.l_iff",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Prims.l_or",
"Vale.Interop.update_buffer_up_mem_aux",
"Prims.Cons",
"Vale.Interop.Heap_s.InteropHeap",
"Prims.unit",
"FStar.Classical.move_requires",
"Prims.l_not",
"Prims.eq2",
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.length",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.get_seq_heap",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Interop.get_seq_heap_as_seq",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words_s.nat64",
"Prims.logical",
"Vale.Interop.Types.addr_map_pred",
"Vale.Interop.Heap_s.list_disjoint_or_eq_reveal",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Lib.BufferViewHelpers.lemma_dv_equal",
"Vale.Interop.Types.down_view",
"FStar.Monotonic.HyperStack.mem",
"LowStar.BufferView.Down.upd_seq",
"LowStar.BufferView.Down.upd_seq_spec",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Types.addr_map",
"Vale.Interop.Heap_s.addrs_of_mem",
"LowStar.BufferView.Down.buffer",
"FStar.Set.equal",
"Prims.int",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Vale.Interop.Heap_s.addrs_set",
"Vale.Interop.Heap_s.correct_down_p",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"Vale.Interop.op_String_Access",
"Vale.Interop.Heap_s.correct_down",
"Vale.Interop.up_mem_aux"
] | [] | module Vale.Interop
open FStar.Mul
module List = FStar.List.Tot.Base
module HS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
module DV = LowStar.BufferView.Down
open Vale.Def.Opaque_s
//open Vale.Interop.Base
open Vale.Lib.BufferViewHelpers
#reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1"
(* Write a buffer in the vale memory *)
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)})
: Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
write_vale_mem contents length addr (i+1) heap
)
let rec frame_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)}
0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
(j:int) : Lemma
(requires j < addr \/ j >= addr + length)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
curr_heap.[j] == new_heap.[j]))
(decreases (length - i))=
if i >= length then ()
else (
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
frame_write_vale_mem contents length addr (i+1) heap j
)
let rec load_store_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)})
: Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j]))
(decreases (length - i))
=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
load_store_write_vale_mem contents length addr (i+1) heap
end
let rec domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==>
addr <= j /\ j < addr + length))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain_write_vale_mem contents length addr (i+1) heap
end
let rec domain2_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap))
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
domain2_write_vale_mem contents length addr (i+1) heap
end
let rec monotone_domain_write_vale_mem
(contents:Seq.seq UInt8.t)
(length:nat{length = FStar.Seq.Base.length contents})
addr
(i:nat{i <= length})
(curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==>
curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma
(requires True)
(ensures (let new_heap = write_vale_mem contents length addr i curr_heap in
forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap)))
(decreases (length - i))=
if i >= length then ()
else begin
let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in
monotone_domain_write_vale_mem contents length addr (i+1) heap
end
#set-options "--z3rlimit 40"
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma
(forall p'. p == p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(p == p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
load_store_write_vale_mem contents length addr 0 heap
in
Classical.forall_intro aux
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma
(forall p'. disjoint p p' /\ correct_down_p mem heap p' ==>
(let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let rec aux (p':b8) : Lemma
(disjoint p p' /\ correct_down_p mem heap p' ==> (
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
correct_down_p mem new_heap p')) =
let b = get_downview p.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem p in
let new_heap = write_vale_mem contents length addr 0 heap in
reveal_opaque (`%addr_map_pred) addr_map_pred;
Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap))
in
Classical.forall_intro aux
let rec addrs_ptr_lemma
(i:nat)
(addrs:addr_map)
(ptr:b8{i <= DV.length (get_downview ptr.bsrc)})
(acc:Set.set int)
(x:int) : Lemma
(requires True)
(ensures Set.mem x (addrs_ptr i addrs ptr acc) <==>
((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc))
(decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then ()
else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma
(requires True)
(ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==>
((exists (b:b8{List.memP b ptrs}).
addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with
| [] -> ()
| a::q ->
let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in
addrs_ptr_lemma 0 addrs a acc' x;
addrs_set_lemma_aux addrs q acc x
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) =
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
write_vale_mem contents length addr 0 heap
let rec down_mem_aux
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p}) : GTot
(heap:machine_heap{forall p. {:pattern List.memP p ptrs}
List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with
| [] -> h
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
down_mem_aux ptrs mem q (a::accu) new_heap
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma
(Set.equal
(Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty))
(Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in
let s1 = Map.domain heap in
let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in
let s3 = Map.domain new_heap in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
domain_write_vale_mem contents length addr 0 heap;
domain2_write_vale_mem contents length addr 0 heap;
Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty);
monotone_domain_write_vale_mem contents length addr 0 heap
let rec lemma_down_mem_aux_domain
(ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern correct_down_p mem h p}
List.memP p accu ==> correct_down_p mem h p})
(x:int) : Lemma
(requires Set.mem x (Map.domain h) <==>
(exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
)
(ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==>
(exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)}
addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))
) = match ps with
| [] -> ()
| a::tl ->
lemma_write_buffer_domain a h mem;
addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x;
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
let down_mem mem =
(* Dummy heap *)
let heap = FStar.Map.const 0 in
let heap = Map.restrict Set.empty heap in
let ptrs = ptrs_of_mem mem in
let heap_f = down_mem_aux ptrs mem ptrs [] heap in
let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) =
addrs_set_lemma_all ();
lemma_down_mem_aux_domain ptrs mem ptrs [] heap x
in Classical.forall_intro aux;
heap_f
private
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs})
(mem:interop_heap)
(ps:list b8)
(accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu})
(h:machine_heap{forall p. {:pattern List.memP p accu}
List.memP p accu ==> correct_down_p mem h p})
(i:int) : Lemma
(requires (forall (b:b8{List.memP b ps}).
let base = addrs_of_mem mem b in
i < base \/ i >= base + DV.length (get_downview b.bsrc)))
(ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) =
match ps with
| [] -> ()
| a::q ->
let new_heap = write_buffer_vale a h mem in
let b = get_downview a.bsrc in
let length = DV.length b in
let contents = DV.as_seq (hs_of_mem mem) b in
let addr = addrs_of_mem mem a in
load_store_write_vale_mem contents length addr 0 h;
correct_down_p_cancel mem h a;
correct_down_p_frame mem h a;
list_disjoint_or_eq_reveal ();
frame_down_mem_aux ptrs mem q (a::accu) new_heap i;
frame_write_vale_mem contents length addr 0 h i
val same_unspecified_down_aux:
(hs1: HS.mem) ->
(hs2: HS.mem) ->
(ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) ->
(i:int) ->
Lemma (
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heap1 = down_mem mem1 in
let heap2 = down_mem mem2 in
not (valid_addr mem1 i) ==>
heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all ();
let heap = Map.const 0 in
let heap = Map.restrict Set.empty heap in
let mem1 = mem_of_hs_roots ptrs hs1 in
let mem2 = mem_of_hs_roots ptrs hs2 in
let addrs = addrs_of_mem mem1 in
let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in
let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in
Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i;
Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma
(requires correct_down_p mem heap1 b /\
(forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x]))
(ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
let rec up_mem_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\
(forall p. List.memP p accu ==> correct_down_p m h p) /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot
(m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\
correct_down m' h}) =
match ps with
| [] -> m
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
DV.upd_seq_spec (hs_of_mem m) b s;
let m' = DV.upd_seq (hs_of_mem m) b s in
let aux1 (p:b8) : Lemma
(requires MB.live (hs_of_mem m) p.bsrc /\
MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc))
(ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc))
= lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m'
in Classical.forall_intro (Classical.move_requires aux1);
list_disjoint_or_eq_reveal ();
up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
let rec down_up_identity_aux
(h:machine_heap)
(ps:list b8)
(accu:list b8)
(m:interop_heap{correct_down m h /\
(forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)})
: Lemma (m == up_mem_aux h ps accu m) =
match ps with
| [] -> ()
| hd::tl ->
let s = get_seq_heap h (addrs_of_mem m) hd in
let b = get_downview hd.bsrc in
let m' = DV.upd_seq (hs_of_mem m) b s in
DV.upd_seq_spec (hs_of_mem m) b s;
assert (Seq.equal s (DV.as_seq (hs_of_mem m) b));
(* The previous assertion and lemma ensure that m == m' *)
down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
let down_up_identity mem =
let heap = down_mem mem in
down_up_identity_aux heap (ptrs_of_mem mem) [] mem
// Selecting a buffer index in any corresponding map of bytes always yields the same result
let correct_down_p_same_sel
(mem:interop_heap)
(heap1 heap2:machine_heap)
(x:int)
(b:b8) : Lemma
(requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)
/\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b))
(ensures Map.sel heap1 x == Map.sel heap2 x) =
let addrs = addrs_of_mem mem in
let i = x - addrs b in
assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i));
assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i))
let up_down_identity_aux
(mem:interop_heap)
(init_heap:machine_heap{correct_down mem init_heap})
(x:int) : Lemma
(requires Map.contains init_heap x)
(ensures Map.sel init_heap x == Map.sel (down_mem mem) x) =
let ptrs = ptrs_of_mem mem in
let addrs = addrs_of_mem mem in
addrs_set_lemma_all ();
Classical.forall_intro
(Classical.move_requires
(correct_down_p_same_sel mem (down_mem mem) init_heap x)
)
let up_down_identity mem heap =
let new_heap = down_mem (up_mem heap mem) in
same_unspecified_down (hs_of_mem mem) (hs_of_mem (up_mem heap mem)) (ptrs_of_mem mem);
let aux (x:int) : Lemma
(requires Map.contains heap x)
(ensures Map.sel heap x == Map.sel new_heap x) =
up_down_identity_aux (up_mem heap mem) heap x
in Classical.forall_intro (Classical.move_requires aux);
assert (Map.equal heap new_heap)
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 1 --initial_fuel 1 --initial_ifuel 1"
let rec update_buffer_up_mem_aux
(h1 h2:machine_heap)
(ps:list b8)
(accu:list b8)
(b:b8)
(m:interop_heap{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu}) : Lemma
(requires
List.memP b (ptrs_of_mem m) /\
Set.equal (Map.domain h1) (addrs_set m) /\
Set.equal (Map.domain h2) (addrs_set m) /\
(forall p. List.memP p accu ==> correct_down_p m h2 p) /\
(List.memP b accu ==> DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\
(forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\
(forall x. x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==>
h1.[x] == h2.[x])
)
(ensures
(List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\
(~(List.memP b accu) ==> hs_of_mem (up_mem_aux h2 ps accu m) == | false | false | Vale.Interop.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_buffer_up_mem_aux
(h1 h2: machine_heap)
(ps accu: list b8)
(b: b8)
(m:
interop_heap
{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu})
: Lemma
(requires
List.memP b (ptrs_of_mem m) /\ Set.equal (Map.domain h1) (addrs_set m) /\
Set.equal (Map.domain h2) (addrs_set m) /\
(forall p. List.memP p accu ==> correct_down_p m h2 p) /\
(List.memP b accu ==>
DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\
(forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\
(forall x.
x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==>
h1.[ x ] == h2.[ x ]))
(ensures
(List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\
(~(List.memP b accu) ==>
hs_of_mem (up_mem_aux h2 ps accu m) ==
DV.upd_seq (hs_of_mem m) (get_downview b.bsrc) (get_seq_heap h2 (addrs_of_mem m) b))) | [
"recursion"
] | Vale.Interop.update_buffer_up_mem_aux | {
"file_name": "vale/code/arch/x64/Vale.Interop.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h1: Vale.Arch.MachineHeap_s.machine_heap ->
h2: Vale.Arch.MachineHeap_s.machine_heap ->
ps: Prims.list Vale.Interop.Types.b8 ->
accu: Prims.list Vale.Interop.Types.b8 ->
b: Vale.Interop.Types.b8 ->
m:
Vale.Interop.Heap_s.interop_heap
{ forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p (Vale.Interop.Heap_s.ptrs_of_mem m) <==>
FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu }
-> FStar.Pervasives.Lemma
(requires
FStar.List.Tot.Base.memP b (Vale.Interop.Heap_s.ptrs_of_mem m) /\
FStar.Set.equal (FStar.Map.domain h1) (Vale.Interop.Heap_s.addrs_set m) /\
FStar.Set.equal (FStar.Map.domain h2) (Vale.Interop.Heap_s.addrs_set m) /\
(forall (p: Vale.Interop.Types.b8).
FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p m h2 p) /\
(FStar.List.Tot.Base.memP b accu ==>
LowStar.BufferView.Down.as_seq (Vale.Interop.Heap_s.hs_of_mem m)
(Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==
Vale.Interop.get_seq_heap h2 (Vale.Interop.Heap_s.addrs_of_mem m) b) /\
(forall (p: Vale.Interop.Types.b8).
~(p == b) /\ FStar.List.Tot.Base.memP p (Vale.Interop.Heap_s.ptrs_of_mem m) ==>
Vale.Interop.Heap_s.correct_down_p m h1 p) /\
(forall (x: Prims.int).
x < Vale.Interop.Heap_s.addrs_of_mem m b \/
x >=
Vale.Interop.Heap_s.addrs_of_mem m b +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==>
h1.[ x ] == h2.[ x ]))
(ensures
(FStar.List.Tot.Base.memP b accu ==> Vale.Interop.up_mem_aux h2 ps accu m == m) /\
(~(FStar.List.Tot.Base.memP b accu) ==>
Vale.Interop.Heap_s.hs_of_mem (Vale.Interop.up_mem_aux h2 ps accu m) ==
LowStar.BufferView.Down.upd_seq (Vale.Interop.Heap_s.hs_of_mem m)
(Vale.Interop.Types.get_downview (Buffer?.bsrc b))
(Vale.Interop.get_seq_heap h2 (Vale.Interop.Heap_s.addrs_of_mem m) b))) | {
"end_col": 78,
"end_line": 489,
"start_col": 2,
"start_line": 466
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 | let live4
#a
#len
(h: mem)
(b0: lbuffer a len)
(b1: lbuffer a len)
(b2: lbuffer a len)
(b3: lbuffer a len)
= | false | null | false | live h b0 /\ live h b1 /\ live h b2 /\ live h b3 | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0" | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val live4 : h: FStar.Monotonic.HyperStack.mem ->
b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len
-> Prims.logical | [] | Lib.MultiBuffer.live4 | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len
-> Prims.logical | {
"end_col": 50,
"end_line": 16,
"start_col": 2,
"start_line": 16
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 | let internally_disjoint4
#len
#a
(b0: lbuffer a len)
(b1: lbuffer a len)
(b2: lbuffer a len)
(b3: lbuffer a len)
= | false | null | false | disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\
disjoint b2 b3 | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.l_and",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val internally_disjoint4 : b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len
-> Prims.logical | [] | Lib.MultiBuffer.internally_disjoint4 | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len
-> Prims.logical | {
"end_col": 52,
"end_line": 23,
"start_col": 2,
"start_line": 22
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b' | let disjoint_multi #lanes #len #a #len' (b: multibuf lanes len) (b': lbuffer a len') = | false | null | false | forall i. i < lanes ==> disjoint b.(| i |) b' | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Lib.MultiBuffer.multibuf",
"Lib.Buffer.lbuffer",
"Prims.l_Forall",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.NTuple.op_Lens_Access",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val disjoint_multi : b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.Buffer.lbuffer a len' -> Prims.logical | [] | Lib.MultiBuffer.disjoint_multi | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.Buffer.lbuffer a len' -> Prims.logical | {
"end_col": 45,
"end_line": 41,
"start_col": 2,
"start_line": 41
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) =
modifies (loc_multi b) h0 h1 | let modifies_multi #lanes #len (b: multibuf lanes len) (h0: mem) (h1: mem) = | false | null | false | modifies (loc_multi b) h0 h1 | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Lib.MultiBuffer.multibuf",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"Lib.MultiBuffer.loc_multi"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|) | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_multi : b: Lib.MultiBuffer.multibuf lanes len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.MultiBuffer.modifies_multi | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.MultiBuffer.multibuf lanes len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 30,
"end_line": 74,
"start_col": 2,
"start_line": 74
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes | let multibuf (lanes: flen) (len: size_t) = | false | null | false | ntuple (lbuffer uint8 len) lanes | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7 | false | true | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val multibuf : lanes: Lib.NTuple.flen -> len: Lib.IntTypes.size_t -> Type0 | [] | Lib.MultiBuffer.multibuf | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | lanes: Lib.NTuple.flen -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 34,
"end_line": 35,
"start_col": 2,
"start_line": 35
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 | let live8
#a
#len
(h: mem)
(b0: lbuffer a len)
(b1: lbuffer a len)
(b2: lbuffer a len)
(b3: lbuffer a len)
(b4: lbuffer a len)
(b5: lbuffer a len)
(b6: lbuffer a len)
(b7: lbuffer a len)
= | false | null | false | live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val live8 : h: FStar.Monotonic.HyperStack.mem ->
b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len ->
b4: Lib.Buffer.lbuffer a len ->
b5: Lib.Buffer.lbuffer a len ->
b6: Lib.Buffer.lbuffer a len ->
b7: Lib.Buffer.lbuffer a len
-> Prims.logical | [] | Lib.MultiBuffer.live8 | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len ->
b4: Lib.Buffer.lbuffer a len ->
b5: Lib.Buffer.lbuffer a len ->
b6: Lib.Buffer.lbuffer a len ->
b7: Lib.Buffer.lbuffer a len
-> Prims.logical | {
"end_col": 102,
"end_line": 19,
"start_col": 2,
"start_line": 19
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let op_Lens_Assignment #a #len = upd #a #len | let op_Lens_Assignment #a #len = | false | null | false | upd #a #len | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.NTuple.upd",
"Lib.NTuple.ntuple",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|)
let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) =
modifies (loc_multi b) h0 h1
let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) =
forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s
let multiseq (lanes:flen) (len:nat) =
ntuple (Seq.lseq uint8 len) lanes
let as_seq_multi #lanes #len (h:mem) (b:multibuf lanes len) : GTot (multiseq lanes (v len)) =
gmap (as_seq h) b
let as_seq_multi_lemma (#lanes:flen) #len h b (i:nat{i < lanes}):
Lemma ((as_seq_multi #lanes #len h b).(|i|) == as_seq h b.(|i|))
[SMTPat (as_seq_multi #lanes #len h b).(|i|)]
=
index_gmap_lemma (as_seq h) b i | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Lens_Assignment : s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> x: a -> Lib.NTuple.ntuple a len | [] | Lib.MultiBuffer.op_Lens_Assignment | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> x: a -> Lib.NTuple.ntuple a len | {
"end_col": 51,
"end_line": 92,
"start_col": 40,
"start_line": 92
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let multiseq (lanes:flen) (len:nat) =
ntuple (Seq.lseq uint8 len) lanes | let multiseq (lanes: flen) (len: nat) = | false | null | false | ntuple (Seq.lseq uint8 len) lanes | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Prims.nat",
"Lib.NTuple.ntuple",
"FStar.Seq.Properties.lseq",
"Lib.IntTypes.uint8"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|)
let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) =
modifies (loc_multi b) h0 h1
let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) =
forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s | false | true | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val multiseq : lanes: Lib.NTuple.flen -> len: Prims.nat -> Type0 | [] | Lib.MultiBuffer.multiseq | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | lanes: Lib.NTuple.flen -> len: Prims.nat -> Type0 | {
"end_col": 35,
"end_line": 80,
"start_col": 2,
"start_line": 80
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let op_Lens_Access #a #len = index #a #len | let op_Lens_Access #a #len = | false | null | false | index #a #len | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.NTuple.index",
"Lib.NTuple.ntuple",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|)
let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) =
modifies (loc_multi b) h0 h1
let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) =
forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s
let multiseq (lanes:flen) (len:nat) =
ntuple (Seq.lseq uint8 len) lanes
let as_seq_multi #lanes #len (h:mem) (b:multibuf lanes len) : GTot (multiseq lanes (v len)) =
gmap (as_seq h) b
let as_seq_multi_lemma (#lanes:flen) #len h b (i:nat{i < lanes}):
Lemma ((as_seq_multi #lanes #len h b).(|i|) == as_seq h b.(|i|))
[SMTPat (as_seq_multi #lanes #len h b).(|i|)]
=
index_gmap_lemma (as_seq h) b i | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Lens_Access : s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> a | [] | Lib.MultiBuffer.op_Lens_Access | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> a | {
"end_col": 49,
"end_line": 91,
"start_col": 36,
"start_line": 91
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|) | let live_multi #lanes #len (h: mem) (b: multibuf lanes len) = | false | null | false | forall i. i < lanes ==> live h b.(| i |) | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.MultiBuffer.multibuf",
"Prims.l_Forall",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.NTuple.op_Lens_Access",
"Lib.Buffer.lbuffer",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|) | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val live_multi : h: FStar.Monotonic.HyperStack.mem -> b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical | [] | Lib.MultiBuffer.live_multi | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical | {
"end_col": 40,
"end_line": 71,
"start_col": 2,
"start_line": 71
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7 | let internally_disjoint8
#len
#a
(b0: lbuffer a len)
(b1: lbuffer a len)
(b2: lbuffer a len)
(b3: lbuffer a len)
(b4: lbuffer a len)
(b5: lbuffer a len)
(b6: lbuffer a len)
(b7: lbuffer a len)
= | false | null | false | disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\
disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\
disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\
disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\
disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.l_and",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val internally_disjoint8 : b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len ->
b4: Lib.Buffer.lbuffer a len ->
b5: Lib.Buffer.lbuffer a len ->
b6: Lib.Buffer.lbuffer a len ->
b7: Lib.Buffer.lbuffer a len
-> Prims.logical | [] | Lib.MultiBuffer.internally_disjoint8 | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b0: Lib.Buffer.lbuffer a len ->
b1: Lib.Buffer.lbuffer a len ->
b2: Lib.Buffer.lbuffer a len ->
b3: Lib.Buffer.lbuffer a len ->
b4: Lib.Buffer.lbuffer a len ->
b5: Lib.Buffer.lbuffer a len ->
b6: Lib.Buffer.lbuffer a len ->
b7: Lib.Buffer.lbuffer a len
-> Prims.logical | {
"end_col": 16,
"end_line": 32,
"start_col": 2,
"start_line": 26
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) | let internally_disjoint #lanes #len (b: multibuf lanes len) = | false | null | false | forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(| i |) b.(| j |) | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Lib.MultiBuffer.multibuf",
"Prims.l_Forall",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.op_disEquality",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.NTuple.op_Lens_Access",
"Lib.Buffer.lbuffer",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val internally_disjoint : b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical | [] | Lib.MultiBuffer.internally_disjoint | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical | {
"end_col": 77,
"end_line": 38,
"start_col": 2,
"start_line": 38
} |
|
Prims.GTot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) | let loc_multi #lanes #len b = | false | null | false | normalize_term (loc_multi_ #lanes #len 0 b) | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"sometrivial"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Lib.MultiBuffer.multibuf",
"FStar.Pervasives.normalize_term",
"LowStar.Monotonic.Buffer.loc",
"Lib.MultiBuffer.loc_multi_"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_multi : b: Lib.MultiBuffer.multibuf lanes len -> Prims.GTot LowStar.Monotonic.Buffer.loc | [] | Lib.MultiBuffer.loc_multi | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.MultiBuffer.multibuf lanes len -> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 73,
"end_line": 49,
"start_col": 30,
"start_line": 49
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|) | let disjoint_multi_multi #lanes #len #len' (b: multibuf lanes len) (b': multibuf lanes len') = | false | null | false | forall i. i < lanes ==> disjoint b.(| i |) b'.(| i |) | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Lib.MultiBuffer.multibuf",
"Prims.l_Forall",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.NTuple.op_Lens_Access",
"Lib.Buffer.lbuffer",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val disjoint_multi_multi : b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.MultiBuffer.multibuf lanes len' -> Prims.logical | [] | Lib.MultiBuffer.disjoint_multi_multi | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.MultiBuffer.multibuf lanes len' -> Prims.logical | {
"end_col": 51,
"end_line": 68,
"start_col": 2,
"start_line": 68
} |
|
Prims.GTot | val loc_multi_ (#lanes: flen) (#len: _) (i: nat{i < lanes}) (b: multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b | val loc_multi_ (#lanes: flen) (#len: _) (i: nat{i < lanes}) (b: multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i))
let rec loc_multi_ (#lanes: flen) #len (i: nat{i < lanes}) (b: multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) = | false | null | false | if i = lanes - 1 then loc (b.(| i |)) else loc b.(| i |) |+| loc_multi_ (i + 1) b | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"sometrivial",
""
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.MultiBuffer.multibuf",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Subtraction",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.NTuple.op_Lens_Access",
"Lib.Buffer.lbuffer",
"Prims.bool",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.MultiBuffer.loc_multi_",
"Prims.op_Addition",
"LowStar.Monotonic.Buffer.loc"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_multi_ (#lanes: flen) (#len: _) (i: nat{i < lanes}) (b: multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) | [
"recursion"
] | Lib.MultiBuffer.loc_multi_ | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Prims.nat{i < lanes} -> b: Lib.MultiBuffer.multibuf lanes len
-> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 41,
"end_line": 47,
"start_col": 2,
"start_line": 46
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) =
forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s | let stack_allocated_multi
#lanes
#len
(b: multibuf lanes len)
(h0: mem)
(h1: mem)
(s: lseq uint8 (v len))
= | false | null | false | forall i. i < lanes ==> stack_allocated b.(| i |) h0 h1 s | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"total"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"Lib.MultiBuffer.multibuf",
"FStar.Monotonic.HyperStack.mem",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.l_Forall",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Lib.Buffer.stack_allocated",
"Lib.NTuple.op_Lens_Access",
"Lib.Buffer.lbuffer",
"Prims.logical"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|)
let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) =
modifies (loc_multi b) h0 h1 | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stack_allocated_multi : b: Lib.MultiBuffer.multibuf lanes len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
s: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.v len)
-> Prims.logical | [] | Lib.MultiBuffer.stack_allocated_multi | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.MultiBuffer.multibuf lanes len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
s: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.v len)
-> Prims.logical | {
"end_col": 57,
"end_line": 77,
"start_col": 2,
"start_line": 77
} |
|
Prims.GTot | val as_seq_multi (#lanes #len: _) (h: mem) (b: multibuf lanes len) : GTot (multiseq lanes (v len)) | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let as_seq_multi #lanes #len (h:mem) (b:multibuf lanes len) : GTot (multiseq lanes (v len)) =
gmap (as_seq h) b | val as_seq_multi (#lanes #len: _) (h: mem) (b: multibuf lanes len) : GTot (multiseq lanes (v len))
let as_seq_multi #lanes #len (h: mem) (b: multibuf lanes len) : GTot (multiseq lanes (v len)) = | false | null | false | gmap (as_seq h) b | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"sometrivial"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.MultiBuffer.multibuf",
"Lib.NTuple.gmap",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.Seq.Properties.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.MultiBuffer.multiseq"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|)
let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) =
modifies (loc_multi b) h0 h1
let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) =
forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s
let multiseq (lanes:flen) (len:nat) =
ntuple (Seq.lseq uint8 len) lanes | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_seq_multi (#lanes #len: _) (h: mem) (b: multibuf lanes len) : GTot (multiseq lanes (v len)) | [] | Lib.MultiBuffer.as_seq_multi | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> b: Lib.MultiBuffer.multibuf lanes len
-> Prims.GTot (Lib.MultiBuffer.multiseq lanes (Lib.IntTypes.v len)) | {
"end_col": 19,
"end_line": 83,
"start_col": 2,
"start_line": 83
} |
FStar.Pervasives.Lemma | val as_seq_multi_lemma (#lanes: flen) (#len h b: _) (i: nat{i < lanes})
: Lemma ((as_seq_multi #lanes #len h b).(| i |) == as_seq h b.(| i |))
[SMTPat (as_seq_multi #lanes #len h b).(| i |)] | [
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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
}
] | false | let as_seq_multi_lemma (#lanes:flen) #len h b (i:nat{i < lanes}):
Lemma ((as_seq_multi #lanes #len h b).(|i|) == as_seq h b.(|i|))
[SMTPat (as_seq_multi #lanes #len h b).(|i|)]
=
index_gmap_lemma (as_seq h) b i | val as_seq_multi_lemma (#lanes: flen) (#len h b: _) (i: nat{i < lanes})
: Lemma ((as_seq_multi #lanes #len h b).(| i |) == as_seq h b.(| i |))
[SMTPat (as_seq_multi #lanes #len h b).(| i |)]
let as_seq_multi_lemma (#lanes: flen) #len h b (i: nat{i < lanes})
: Lemma ((as_seq_multi #lanes #len h b).(| i |) == as_seq h b.(| i |))
[SMTPat (as_seq_multi #lanes #len h b).(| i |)] = | false | null | true | index_gmap_lemma (as_seq h) b i | {
"checked_file": "Lib.MultiBuffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.MultiBuffer.fst"
} | [
"lemma"
] | [
"Lib.NTuple.flen",
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.NTuple.index_gmap_lemma",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"FStar.Seq.Base.length",
"Lib.NTuple.op_Lens_Access",
"FStar.Seq.Properties.lseq",
"Lib.MultiBuffer.as_seq_multi",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module Lib.MultiBuffer
open FStar.Mul
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Sequence
open Lib.Buffer
open Lib.NTuple
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\
disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\
disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\
disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\
disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\
disjoint b5 b6 /\ disjoint b5 b7 /\
disjoint b6 b7
inline_for_extraction let multibuf (lanes:flen) (len:size_t) =
ntuple (lbuffer uint8 len) lanes
let internally_disjoint #lanes #len (b:multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') =
forall i. i < lanes ==> disjoint b.(|i|) b'
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len)
: GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(|i|))
else loc b.(|i|) |+| loc_multi_ (i+1) b
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == loc b.(|0|)) = ()
#push-options "--fuel 4"
let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = ()
#pop-options
#push-options "--fuel 8"
let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) :
Lemma (loc_multi #lanes #len b ==
(loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+|
(loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) =
()
#pop-options
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) =
forall i. i < lanes ==> live h b.(|i|)
let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) =
modifies (loc_multi b) h0 h1
let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) =
forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s
let multiseq (lanes:flen) (len:nat) =
ntuple (Seq.lseq uint8 len) lanes
let as_seq_multi #lanes #len (h:mem) (b:multibuf lanes len) : GTot (multiseq lanes (v len)) =
gmap (as_seq h) b
let as_seq_multi_lemma (#lanes:flen) #len h b (i:nat{i < lanes}):
Lemma ((as_seq_multi #lanes #len h b).(|i|) == as_seq h b.(|i|))
[SMTPat (as_seq_multi #lanes #len h b).(|i|)] | false | false | Lib.MultiBuffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_seq_multi_lemma (#lanes: flen) (#len h b: _) (i: nat{i < lanes})
: Lemma ((as_seq_multi #lanes #len h b).(| i |) == as_seq h b.(| i |))
[SMTPat (as_seq_multi #lanes #len h b).(| i |)] | [] | Lib.MultiBuffer.as_seq_multi_lemma | {
"file_name": "lib/Lib.MultiBuffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
b: Lib.NTuple.ntuple (Lib.Buffer.lbuffer_t Lib.Buffer.MUT Lib.IntTypes.uint8 len) lanes ->
i: Prims.nat{i < lanes}
-> FStar.Pervasives.Lemma
(ensures ( .(||) ) (Lib.MultiBuffer.as_seq_multi h b) i == Lib.Buffer.as_seq h (( .(||) ) b i)
) [SMTPat (( .(||) ) (Lib.MultiBuffer.as_seq_multi h b) i)] | {
"end_col": 33,
"end_line": 89,
"start_col": 2,
"start_line": 89
} |
Prims.Tot | val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: erased a) : vprop | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"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": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"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
}
] | false | let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : vprop =
to_vprop (pts_to_sl r f v) | val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: erased a) : vprop
let pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: erased a) : vprop = | false | null | false | to_vprop (pts_to_sl r f v) | {
"checked_file": "Steel.MonotonicHigherReference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.MonotonicHigherReference.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"Steel.MonotonicHigherReference.ref",
"Steel.FractionalPermission.perm",
"FStar.Ghost.erased",
"Steel.Effect.Common.to_vprop",
"Steel.MonotonicHigherReference.pts_to_sl",
"Steel.Effect.Common.vprop"
] | [] | (*
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.MonotonicHigherReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
val ref (a:Type u#1) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__] | false | false | Steel.MonotonicHigherReference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: erased a) : vprop | [] | Steel.MonotonicHigherReference.pts_to | {
"file_name": "lib/steel/Steel.MonotonicHigherReference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
r: Steel.MonotonicHigherReference.ref a p ->
f: Steel.FractionalPermission.perm ->
v: FStar.Ghost.erased a
-> Steel.Effect.Common.vprop | {
"end_col": 28,
"end_line": 43,
"start_col": 2,
"start_line": 43
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"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": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"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
}
] | false | let property (a:Type)
= a -> prop | let property (a: Type) = | false | null | false | a -> prop | {
"checked_file": "Steel.MonotonicHigherReference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.MonotonicHigherReference.fsti"
} | [
"total"
] | [
"Prims.prop"
] | [] | (*
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.MonotonicHigherReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
val ref (a:Type u#1) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__]
unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : vprop =
to_vprop (pts_to_sl r f v)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelT (ref a p) emp (fun r -> pts_to r full_perm v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine (#a:Type) (#q:perm) (#p:Preorder.preorder a) (#frame:a -> vprop)
(r:ref a p)
: SteelT a (h_exists (fun (v:a) -> pts_to r q v `star` frame v))
(fun v -> pts_to r q v `star` frame v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write (#a:Type) (#p:Preorder.preorder a) (#v:erased a)
(r:ref a p) (x:a)
: Steel unit (pts_to r full_perm v)
(fun v -> pts_to r full_perm x)
(requires fun _ -> p v x /\ True)
(ensures fun _ _ _ -> True)
/// A wrapper around a predicate that depends on a value of type [a] | false | true | Steel.MonotonicHigherReference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val property : a: Type -> Type | [] | Steel.MonotonicHigherReference.property | {
"file_name": "lib/steel/Steel.MonotonicHigherReference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type -> Type | {
"end_col": 13,
"end_line": 67,
"start_col": 4,
"start_line": 67
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"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": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"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
}
] | false | let stable_property (#a:Type) (p:Preorder.preorder a)
= fact:property a { Preorder.stable fact p } | let stable_property (#a: Type) (p: Preorder.preorder a) = | false | null | false | fact: property a {Preorder.stable fact p} | {
"checked_file": "Steel.MonotonicHigherReference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.MonotonicHigherReference.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"Steel.MonotonicHigherReference.property",
"FStar.Preorder.stable"
] | [] | (*
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.MonotonicHigherReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
val ref (a:Type u#1) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__]
unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : vprop =
to_vprop (pts_to_sl r f v)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelT (ref a p) emp (fun r -> pts_to r full_perm v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine (#a:Type) (#q:perm) (#p:Preorder.preorder a) (#frame:a -> vprop)
(r:ref a p)
: SteelT a (h_exists (fun (v:a) -> pts_to r q v `star` frame v))
(fun v -> pts_to r q v `star` frame v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write (#a:Type) (#p:Preorder.preorder a) (#v:erased a)
(r:ref a p) (x:a)
: Steel unit (pts_to r full_perm v)
(fun v -> pts_to r full_perm x)
(requires fun _ -> p v x /\ True)
(ensures fun _ _ _ -> True)
/// A wrapper around a predicate that depends on a value of type [a]
let property (a:Type)
= a -> prop
/// A wrapper around a property [fact] that has been witnessed to be true and stable
/// with respect to preorder [p]
val witnessed (#a:Type u#1) (#p:Preorder.preorder a) (r:ref a p) (fact:property a)
: Type0
/// The type of properties depending on values of type [a], and that
/// are stable with respect to the preorder [p] | false | false | Steel.MonotonicHigherReference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stable_property : p: FStar.Preorder.preorder a -> Type | [] | Steel.MonotonicHigherReference.stable_property | {
"file_name": "lib/steel/Steel.MonotonicHigherReference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: FStar.Preorder.preorder a -> Type | {
"end_col": 46,
"end_line": 77,
"start_col": 4,
"start_line": 77
} |
|
Prims.Tot | val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Gctr_blocks128_1way_body0 alg =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Gctr_blocks128_body_1way alg)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_CCons
(va_code_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_CCons (va_code_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_CNil ()))))))) | val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code
let va_code_Gctr_blocks128_1way_body0 alg = | false | null | false | (va_Block (va_CCons (va_code_Mod_cr0 ())
(va_CCons (va_code_Gctr_blocks128_body_1way alg)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16)
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 3))
(va_CNil ()))))))) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.AES.PPC64LE.GCTR.va_code_Mod_cr0",
"Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128_body_1way",
"Vale.PPC64LE.InsBasic.va_code_AddImm",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_code_Vadduwm",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_body_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (plain_quads:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_body_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 152 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 6 va_s + count))) (fun _ -> let (ctr_enc:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 6 va_s + count) (va_get_mem_heaplet 1
va_s))) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 6 va_s + count))) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 154 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 155 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 157 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret in_b (va_get_reg 6 va_s + count)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret out_b (va_get_reg 6 va_s + count)) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 160 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 6
va_s + count) (va_get_mem_heaplet 1 va_s)) == ctr_enc) (let (va_arg24:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg23:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg22:Vale.Def.Types_s.quad32) = old_icb in let (va_arg21:Prims.nat) = va_get_reg 6 va_s +
count in let (va_arg20:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg19:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 162 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg18 va_arg19 va_arg20
va_arg21 va_arg22 va_arg23 va_arg24) (va_QEmpty (())))))))))))
val va_lemma_Gctr_blocks128_body_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> count:nat -> old_icb:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> plain_quads:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_body_1way alg) va_s0 /\ va_get_ok va_s0
/\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count `op_Multiply` 16
/\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_body_1way va_b0 va_s0 alg in_b out_b count old_icb key round_keys
keys_b plain_quads =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_body_1way va_mods alg in_b out_b count old_icb key round_keys
keys_b plain_quads in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_body_1way alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 110 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 148 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 149 column 132 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) (va_get_reg 6 va_sM + count + 1)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 150 column 126 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + count + 1) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (count:nat)
(old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (plain_quads:(seq
quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count
`op_Multiply` 16 /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7
va_s0) out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))
/\ (forall (va_x_mem:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM
/\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_body_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
count:nat -> old_icb:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
plain_quads:(seq quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_body_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count old_icb key round_keys keys_b
plain_quads va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_body_1way (va_code_Gctr_blocks128_body_1way alg)
va_s0 alg in_b out_b count old_icb key round_keys keys_b plain_quads in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_body_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_body_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec
0; va_Mod_reg 10; va_Mod_mem]) (va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads) (va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count
old_icb key round_keys keys_b plain_quads))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Gctr_blocks128_1way_body0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code | [] | Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128_1way_body0 | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_code | {
"end_col": 89,
"end_line": 365,
"start_col": 2,
"start_line": 362
} |
Prims.Tot | val va_code_Gctr_register : alg:algorithm -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ())))))) | val va_code_Gctr_register : alg:algorithm -> Tot va_code
let va_code_Gctr_register alg = | false | null | false | (va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_AESEncryptBlock alg)
(va_CCons (va_Block (va_CNil ()))
(va_CCons (va_code_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0))
(va_CNil ())))))) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsVector.va_code_Vmr",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.InsVector.va_code_Vxor",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Gctr_register : alg:algorithm -> Tot va_code | [] | Vale.AES.PPC64LE.GCTR.va_code_Gctr_register | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_code | {
"end_col": 88,
"end_line": 36,
"start_col": 2,
"start_line": 34
} |
Prims.Tot | val va_wp_Mod_cr0 (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (()))) | val va_wp_Mod_cr0 (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
let va_wp_Mod_cr0 (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 = | false | null | false | (va_get_ok va_s0 /\
(forall (va_x_cr0: cr0_t).
let va_sM = va_upd_cr0 va_x_cr0 va_s0 in
va_get_ok va_sM ==> va_k va_sM (()))) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.l_Forall",
"Vale.PPC64LE.Machine_s.cr0_t",
"Prims.l_imp",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_cr0"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_body_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (plain_quads:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_body_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 152 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 6 va_s + count))) (fun _ -> let (ctr_enc:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 6 va_s + count) (va_get_mem_heaplet 1
va_s))) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 6 va_s + count))) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 154 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 155 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 157 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret in_b (va_get_reg 6 va_s + count)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret out_b (va_get_reg 6 va_s + count)) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 160 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 6
va_s + count) (va_get_mem_heaplet 1 va_s)) == ctr_enc) (let (va_arg24:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg23:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg22:Vale.Def.Types_s.quad32) = old_icb in let (va_arg21:Prims.nat) = va_get_reg 6 va_s +
count in let (va_arg20:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg19:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 162 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg18 va_arg19 va_arg20
va_arg21 va_arg22 va_arg23 va_arg24) (va_QEmpty (())))))))))))
val va_lemma_Gctr_blocks128_body_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> count:nat -> old_icb:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> plain_quads:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_body_1way alg) va_s0 /\ va_get_ok va_s0
/\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count `op_Multiply` 16
/\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_body_1way va_b0 va_s0 alg in_b out_b count old_icb key round_keys
keys_b plain_quads =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_body_1way va_mods alg in_b out_b count old_icb key round_keys
keys_b plain_quads in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_body_1way alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 110 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 148 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 149 column 132 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) (va_get_reg 6 va_sM + count + 1)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 150 column 126 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + count + 1) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (count:nat)
(old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (plain_quads:(seq
quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count
`op_Multiply` 16 /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7
va_s0) out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))
/\ (forall (va_x_mem:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM
/\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_body_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
count:nat -> old_icb:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
plain_quads:(seq quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_body_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count old_icb key round_keys keys_b
plain_quads va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_body_1way (va_code_Gctr_blocks128_body_1way alg)
va_s0 alg in_b out_b count old_icb key round_keys keys_b plain_quads in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_body_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_body_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec
0; va_Mod_reg 10; va_Mod_mem]) (va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads) (va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count
old_icb key round_keys keys_b plain_quads))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr] | false | true | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_Mod_cr0 (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 | [] | Vale.AES.PPC64LE.GCTR.va_wp_Mod_cr0 | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 31,
"end_line": 335,
"start_col": 2,
"start_line": 334
} |
Prims.Tot | val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ())))))) | val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
let va_codegen_success_Gctr_blocks128_body_1way alg = | false | null | false | (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_pbool_and (va_codegen_success_AESEncryptBlock alg)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 9)
Secret)
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7)
(va_op_reg_opr_reg 9)
Secret)
(va_ttrue ())))))) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsVector.va_codegen_success_Vmr",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.AES.va_codegen_success_AESEncryptBlock",
"Vale.PPC64LE.InsVector.va_codegen_success_Load128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_codegen_success_Vxor",
"Vale.PPC64LE.InsVector.va_codegen_success_Store128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool | [] | Vale.AES.PPC64LE.GCTR.va_codegen_success_Gctr_blocks128_body_1way | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 96,
"end_line": 130,
"start_col": 2,
"start_line": 124
} |
Prims.Tot | val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Gctr_blocks128_1way_while0 alg =
(va_Block (va_CCons (va_While (va_cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (va_Block
(va_CCons (va_code_Gctr_blocks128_1way_body0 alg) (va_CNil ())))) (va_CNil ()))) | val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code
let va_code_Gctr_blocks128_1way_while0 alg = | false | null | false | (va_Block (va_CCons (va_While (va_cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26))
(va_Block (va_CCons (va_code_Gctr_blocks128_1way_body0 alg) (va_CNil ()))))
(va_CNil ()))) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.Decls.va_While",
"Vale.PPC64LE.Decls.va_cmp_ne",
"Vale.PPC64LE.Decls.va_op_cmp_reg",
"Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128_1way_body0",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_body_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (plain_quads:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_body_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 152 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 6 va_s + count))) (fun _ -> let (ctr_enc:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 6 va_s + count) (va_get_mem_heaplet 1
va_s))) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 6 va_s + count))) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 154 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 155 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 157 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret in_b (va_get_reg 6 va_s + count)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret out_b (va_get_reg 6 va_s + count)) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 160 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 6
va_s + count) (va_get_mem_heaplet 1 va_s)) == ctr_enc) (let (va_arg24:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg23:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg22:Vale.Def.Types_s.quad32) = old_icb in let (va_arg21:Prims.nat) = va_get_reg 6 va_s +
count in let (va_arg20:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg19:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 162 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg18 va_arg19 va_arg20
va_arg21 va_arg22 va_arg23 va_arg24) (va_QEmpty (())))))))))))
val va_lemma_Gctr_blocks128_body_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> count:nat -> old_icb:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> plain_quads:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_body_1way alg) va_s0 /\ va_get_ok va_s0
/\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count `op_Multiply` 16
/\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_body_1way va_b0 va_s0 alg in_b out_b count old_icb key round_keys
keys_b plain_quads =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_body_1way va_mods alg in_b out_b count old_icb key round_keys
keys_b plain_quads in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_body_1way alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 110 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 148 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 149 column 132 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) (va_get_reg 6 va_sM + count + 1)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 150 column 126 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + count + 1) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (count:nat)
(old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (plain_quads:(seq
quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count
`op_Multiply` 16 /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7
va_s0) out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))
/\ (forall (va_x_mem:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM
/\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_body_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
count:nat -> old_icb:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
plain_quads:(seq quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_body_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count old_icb key round_keys keys_b
plain_quads va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_body_1way (va_code_Gctr_blocks128_body_1way alg)
va_s0 alg in_b out_b count old_icb key round_keys keys_b plain_quads in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_body_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_body_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec
0; va_Mod_reg 10; va_Mod_mem]) (va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads) (va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count
old_icb key round_keys keys_b plain_quads))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Gctr_blocks128_1way_body0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_body0 alg =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Gctr_blocks128_body_1way alg)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_CCons
(va_code_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_CCons (va_code_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_CNil ())))))))
val va_codegen_success_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_body0 alg =
(va_pbool_and (va_codegen_success_Mod_cr0 ()) (va_pbool_and
(va_codegen_success_Gctr_blocks128_body_1way alg) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_body0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_body0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 257 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Mod_cr0 ()) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 259 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_body_1way alg in_b out_b (va_get_reg 8 va_s) old_icb key round_keys
keys_b old_plain) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 261 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 262 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 263 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_QEmpty
(()))))))))
val va_lemma_Gctr_blocks128_1way_body0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_body0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) /\ va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_body0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_body0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_body0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 254 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 /\ (forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap)
(va_x_mem:vale_heap) (va_x_ok:bool) (va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64)
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7
(va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok (va_upd_mem va_x_mem (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM
/\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16 `op_Multiply`
va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb
(va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b
va_in_out_b \/ va_in_in_b == va_in_out_b) /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) va_in_in_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) va_in_out_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg
26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8
va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_body0 : va_old:va_state -> alg:algorithm -> va_in_in_b:buffer128
-> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32 ->
va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq quad32) ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_body0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb
va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_body0 (va_code_Gctr_blocks128_1way_body0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_body0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_body0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way_while0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code | [] | Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128_1way_while0 | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_code | {
"end_col": 84,
"end_line": 640,
"start_col": 2,
"start_line": 639
} |
Prims.Tot | val va_qcode_Store_3blocks128_2 (va_mods: va_mods_t) (out_b: buffer128)
: (va_quickCode unit (va_code_Store_3blocks128_2 ())) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_qcode_Store_3blocks128_2 (va_mods:va_mods_t) (out_b:buffer128) : (va_quickCode unit
(va_code_Store_3blocks128_2 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 3)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret out_b (va_get_reg 8 va_s + 3)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 314 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret out_b (va_get_reg 8 va_s + 4)) (fun
(va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 315 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret out_b (va_get_reg 8 va_s + 5)) (va_QEmpty
(())))))) | val va_qcode_Store_3blocks128_2 (va_mods: va_mods_t) (out_b: buffer128)
: (va_quickCode unit (va_code_Store_3blocks128_2 ()))
let va_qcode_Store_3blocks128_2 (va_mods: va_mods_t) (out_b: buffer128)
: (va_quickCode unit (va_code_Store_3blocks128_2 ())) = | false | null | false | (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 3)
(va_op_reg_opr_reg 7)
(va_op_reg_opr_reg 29)
Secret
out_b
(va_get_reg 8 va_s + 3))
(fun (va_s: va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 314 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 7)
(va_op_reg_opr_reg 30)
Secret
out_b
(va_get_reg 8 va_s + 4))
(fun (va_s: va_state) _ ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 315 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 7)
(va_op_reg_opr_reg 31)
Secret
out_b
(va_get_reg 8 va_s + 5))
(va_QEmpty (())))))) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsVector.va_code_Store128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.Arch.HeapTypes_s.Secret",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.InsVector.va_quick_Store128_byte16_buffer_index",
"Prims.op_Addition",
"Vale.PPC64LE.Decls.va_get_reg",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.GCTR.va_code_Store_3blocks128_2"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_body_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (plain_quads:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_body_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 152 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 6 va_s + count))) (fun _ -> let (ctr_enc:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 6 va_s + count) (va_get_mem_heaplet 1
va_s))) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 6 va_s + count))) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 154 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 155 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 157 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret in_b (va_get_reg 6 va_s + count)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret out_b (va_get_reg 6 va_s + count)) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 160 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 6
va_s + count) (va_get_mem_heaplet 1 va_s)) == ctr_enc) (let (va_arg24:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg23:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg22:Vale.Def.Types_s.quad32) = old_icb in let (va_arg21:Prims.nat) = va_get_reg 6 va_s +
count in let (va_arg20:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg19:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 162 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg18 va_arg19 va_arg20
va_arg21 va_arg22 va_arg23 va_arg24) (va_QEmpty (())))))))))))
val va_lemma_Gctr_blocks128_body_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> count:nat -> old_icb:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> plain_quads:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_body_1way alg) va_s0 /\ va_get_ok va_s0
/\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count `op_Multiply` 16
/\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_body_1way va_b0 va_s0 alg in_b out_b count old_icb key round_keys
keys_b plain_quads =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_body_1way va_mods alg in_b out_b count old_icb key round_keys
keys_b plain_quads in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_body_1way alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 110 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 148 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 149 column 132 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) (va_get_reg 6 va_sM + count + 1)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 150 column 126 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + count + 1) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (count:nat)
(old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (plain_quads:(seq
quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count
`op_Multiply` 16 /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7
va_s0) out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))
/\ (forall (va_x_mem:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM
/\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_body_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
count:nat -> old_icb:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
plain_quads:(seq quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_body_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count old_icb key round_keys keys_b
plain_quads va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_body_1way (va_code_Gctr_blocks128_body_1way alg)
va_s0 alg in_b out_b count old_icb key round_keys keys_b plain_quads in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_body_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_body_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec
0; va_Mod_reg 10; va_Mod_mem]) (va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads) (va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count
old_icb key round_keys keys_b plain_quads))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Gctr_blocks128_1way_body0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_body0 alg =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Gctr_blocks128_body_1way alg)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_CCons
(va_code_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_CCons (va_code_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_CNil ())))))))
val va_codegen_success_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_body0 alg =
(va_pbool_and (va_codegen_success_Mod_cr0 ()) (va_pbool_and
(va_codegen_success_Gctr_blocks128_body_1way alg) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_body0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_body0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 257 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Mod_cr0 ()) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 259 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_body_1way alg in_b out_b (va_get_reg 8 va_s) old_icb key round_keys
keys_b old_plain) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 261 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 262 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 263 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_QEmpty
(()))))))))
val va_lemma_Gctr_blocks128_1way_body0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_body0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) /\ va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_body0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_body0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_body0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 254 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 /\ (forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap)
(va_x_mem:vale_heap) (va_x_ok:bool) (va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64)
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7
(va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok (va_upd_mem va_x_mem (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM
/\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16 `op_Multiply`
va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb
(va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b
va_in_out_b \/ va_in_in_b == va_in_out_b) /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) va_in_in_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) va_in_out_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg
26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8
va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_body0 : va_old:va_state -> alg:algorithm -> va_in_in_b:buffer128
-> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32 ->
va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq quad32) ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_body0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb
va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_body0 (va_code_Gctr_blocks128_1way_body0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_body0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_body0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way_while0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_while0 alg =
(va_Block (va_CCons (va_While (va_cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (va_Block
(va_CCons (va_code_Gctr_blocks128_1way_body0 alg) (va_CNil ())))) (va_CNil ())))
val va_codegen_success_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_while0 alg =
(va_pbool_and (va_codegen_success_Gctr_blocks128_1way_body0 alg) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_while0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_while0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_qWhile va_mods (Cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (fun va_g -> qblock va_mods
(fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_1way_body0 va_old alg in_b key keys_b old_icb old_plain out_b
round_keys) (va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_get_ok va_s /\ (0 <= va_get_reg
8 va_s /\ va_get_reg 8 va_s <= va_get_reg 26 va_s) /\ va_get_reg 9 va_s == 16 `op_Multiply`
va_get_reg 8 va_s /\ va_get_vec 7 va_s == Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s
+ va_get_reg 8 va_s) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s) (va_get_reg 3 va_s) in_b
(va_get_reg 6 va_s) (va_get_reg 26 va_s) (va_get_mem_layout va_s) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s) (va_get_reg 7 va_s) out_b
(va_get_reg 6 va_s) (va_get_reg 26 va_s) (va_get_mem_layout va_s) Secret /\ va_get_reg 3 va_s +
16 `op_Multiply` va_get_reg 26 va_s < pow2_64 /\ va_get_reg 7 va_s + 16 `op_Multiply`
va_get_reg 26 va_s < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128
in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b /\ (va_get_reg 8
va_s =!= va_get_reg 26 va_s ==> Vale.AES.GCTR_BE.partial_seq_agreement old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) (va_get_reg 6 va_s + va_get_reg 8 va_s) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b)) /\ va_get_reg 6 va_s + va_get_reg 26 va_s < pow2_32 /\
aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s) (va_get_mem_heaplet 0 va_s)
(va_get_mem_layout va_s) /\ va_get_vec 3 va_s == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 1 0 0 0 /\ Vale.PPC64LE.Decls.modifies_buffer128 out_b
(va_get_mem_heaplet 1 va_old) (va_get_mem_heaplet 1 va_s) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s + va_get_reg 8 va_s) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) out_b)) key old_icb /\ (va_get_reg 6 va_s
+ va_get_reg 26 va_s == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) out_b ==
Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) out_b)) (fun (va_s:va_state) va_g ->
va_get_reg 26 va_s - va_get_reg 8 va_s) (())) (fun (va_s:va_state) va_g -> let va_g = () in
va_QEmpty (()))))
val va_lemma_Gctr_blocks128_1way_while0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_while0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM) /\ va_state_eq va_sM (va_update_vec 7 va_sM
(va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM (va_update_mem_heaplet 1 va_sM
(va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_while0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_while0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_while0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_while0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
(forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap) (va_x_mem:vale_heap) (va_x_ok:bool)
(va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0
(va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8 (va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok
(va_upd_mem va_x_mem (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in
va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\
va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_while0 : va_old:va_state -> alg:algorithm ->
va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32
-> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq quad32) ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_while0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_while0 (va_code_Gctr_blocks128_1way_while0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_while0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_while0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_while0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way alg =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 3) 1) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 4) 0) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3) 4) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_CCons
(va_code_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_CCons (va_code_Gctr_blocks128_1way_while0 alg)
(va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way alg =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 3) 1) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 4) 0) (va_pbool_and (va_codegen_success_Vsldoi
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3) 4) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_pbool_and
(va_codegen_success_Gctr_blocks128_1way_while0 alg) (va_ttrue ())))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (old_icb:quad32) (old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_blocks128_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 3) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 220 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 4) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 221 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 223 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 224 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 226 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_1way_while0 va_old_s alg in_b key keys_b old_icb old_plain out_b
round_keys) (va_QEmpty (())))))))))
val va_lemma_Gctr_blocks128_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> old_icb:quad32 -> old_plain:(seq quad32) -> key:(seq nat32)
-> round_keys:(seq quad32) -> keys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way alg) va_s0 /\ va_get_ok va_s0 /\
((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg
3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 +
va_get_reg 26 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
Vale.AES.GCTR_BE.partial_seq_agreement old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s0) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) key old_icb)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM)
old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) out_b)) key old_icb /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26 va_sM) /\ (va_get_reg 6
va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b
== Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 7 va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way va_b0 va_s0 alg in_b out_b old_icb old_plain key round_keys keys_b
=
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_ok;
va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_1way va_mods alg in_b out_b old_icb old_plain key round_keys
keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 212 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 215 column 118 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM) old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 216 column 51 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 217 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (old_icb:quad32)
(old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg
3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 +
va_get_reg 26 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
Vale.AES.GCTR_BE.partial_seq_agreement old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s0) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) key old_icb) /\ (forall
(va_x_mem:vale_heap) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_v0:quad32)
(va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v7:quad32) (va_x_cr0:cr0_t)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0
(va_upd_vec 7 va_x_v7 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM)
old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) out_b)) key old_icb /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26 va_sM) /\ (va_get_reg 6
va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b
== Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
old_icb:quad32 -> old_plain:(seq quad32) -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key
round_keys keys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_mem]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys keys_b va_s0
va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way (va_code_Gctr_blocks128_1way alg) va_s0 alg
in_b out_b old_icb old_plain key round_keys keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 7
va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0)))))))))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(old_icb:quad32) (old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_blocks128_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7;
va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg
8; va_Mod_mem]) (va_wp_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys
keys_b) (va_wpProof_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys keys_b))
#pop-options
//--
//-- Store_3blocks128_1
val va_code_Store_3blocks128_1 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Store_3blocks128_1 () =
(va_Block (va_CCons (va_code_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret) (va_CNil ())))))
val va_codegen_success_Store_3blocks128_1 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Store_3blocks128_1 () =
(va_pbool_and (va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Store_3blocks128_1 (va_mods:va_mods_t) (out_b:buffer128) : (va_quickCode unit
(va_code_Store_3blocks128_1 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 287 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret out_b (va_get_reg 8 va_s)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 288 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret out_b (va_get_reg 8 va_s + 1)) (fun
(va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 289 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret out_b (va_get_reg 8 va_s + 2)) (va_QEmpty
(()))))))
val va_lemma_Store_3blocks128_1 : va_b0:va_code -> va_s0:va_state -> out_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Store_3blocks128_1 ()) va_s0 /\ va_get_ok va_s0 /\
(va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 8 va_s0) (va_get_reg 6
va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 27 va_s0 == 1
`op_Multiply` 16 /\ va_get_reg 28 va_s0 == 2 `op_Multiply` 16)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))
[@"opaque_to_smt"]
let va_lemma_Store_3blocks128_1 va_b0 va_s0 out_b =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Store_3blocks128_1 va_mods out_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Store_3blocks128_1 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 282 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 284 column 74 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 285 column 74 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Store_3blocks128_1 (out_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 8 va_s0) (va_get_reg 6 va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0)
Secret /\ va_get_reg 27 va_s0 == 1 `op_Multiply` 16 /\ va_get_reg 28 va_s0 == 2 `op_Multiply`
16) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0) in va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)) ==> va_k va_sM (())))
val va_wpProof_Store_3blocks128_1 : out_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Store_3blocks128_1 out_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Store_3blocks128_1 ())
([va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Store_3blocks128_1 out_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Store_3blocks128_1 (va_code_Store_3blocks128_1 ()) va_s0 out_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Store_3blocks128_1 (out_b:buffer128) : (va_quickCode unit (va_code_Store_3blocks128_1
())) =
(va_QProc (va_code_Store_3blocks128_1 ()) ([va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Store_3blocks128_1 out_b) (va_wpProof_Store_3blocks128_1 out_b))
//--
//-- Store_3blocks128_2
val va_code_Store_3blocks128_2 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Store_3blocks128_2 () =
(va_Block (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 3) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret) (va_CNil ())))))
val va_codegen_success_Store_3blocks128_2 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Store_3blocks128_2 () =
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 3) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 4) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Store_3blocks128_2 (va_mods:va_mods_t) (out_b:buffer128) : (va_quickCode unit | false | false | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_qcode_Store_3blocks128_2 (va_mods: va_mods_t) (out_b: buffer128)
: (va_quickCode unit (va_code_Store_3blocks128_2 ())) | [] | Vale.AES.PPC64LE.GCTR.va_qcode_Store_3blocks128_2 | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_mods: Vale.PPC64LE.QuickCode.va_mods_t -> out_b: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GCTR.va_code_Store_3blocks128_2 ()) | {
"end_col": 13,
"end_line": 1261,
"start_col": 2,
"start_line": 1249
} |
Prims.Tot | val va_codegen_success_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Gctr_blocks128_1way_while0 alg =
(va_pbool_and (va_codegen_success_Gctr_blocks128_1way_body0 alg) (va_ttrue ())) | val va_codegen_success_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_pbool
let va_codegen_success_Gctr_blocks128_1way_while0 alg = | false | null | false | (va_pbool_and (va_codegen_success_Gctr_blocks128_1way_body0 alg) (va_ttrue ())) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.AES.PPC64LE.GCTR.va_codegen_success_Gctr_blocks128_1way_body0",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_body_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (plain_quads:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_body_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 152 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 6 va_s + count))) (fun _ -> let (ctr_enc:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 6 va_s + count) (va_get_mem_heaplet 1
va_s))) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 6 va_s + count))) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 154 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 155 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 157 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret in_b (va_get_reg 6 va_s + count)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret out_b (va_get_reg 6 va_s + count)) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 160 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 6
va_s + count) (va_get_mem_heaplet 1 va_s)) == ctr_enc) (let (va_arg24:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg23:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg22:Vale.Def.Types_s.quad32) = old_icb in let (va_arg21:Prims.nat) = va_get_reg 6 va_s +
count in let (va_arg20:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg19:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 162 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg18 va_arg19 va_arg20
va_arg21 va_arg22 va_arg23 va_arg24) (va_QEmpty (())))))))))))
val va_lemma_Gctr_blocks128_body_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> count:nat -> old_icb:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> plain_quads:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_body_1way alg) va_s0 /\ va_get_ok va_s0
/\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count `op_Multiply` 16
/\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_body_1way va_b0 va_s0 alg in_b out_b count old_icb key round_keys
keys_b plain_quads =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_body_1way va_mods alg in_b out_b count old_icb key round_keys
keys_b plain_quads in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_body_1way alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 110 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 148 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 149 column 132 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) (va_get_reg 6 va_sM + count + 1)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 150 column 126 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + count + 1) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (count:nat)
(old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (plain_quads:(seq
quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count
`op_Multiply` 16 /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7
va_s0) out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))
/\ (forall (va_x_mem:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM
/\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_body_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
count:nat -> old_icb:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
plain_quads:(seq quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_body_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count old_icb key round_keys keys_b
plain_quads va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_body_1way (va_code_Gctr_blocks128_body_1way alg)
va_s0 alg in_b out_b count old_icb key round_keys keys_b plain_quads in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_body_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_body_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec
0; va_Mod_reg 10; va_Mod_mem]) (va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads) (va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count
old_icb key round_keys keys_b plain_quads))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Gctr_blocks128_1way_body0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_body0 alg =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Gctr_blocks128_body_1way alg)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_CCons
(va_code_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_CCons (va_code_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_CNil ())))))))
val va_codegen_success_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_body0 alg =
(va_pbool_and (va_codegen_success_Mod_cr0 ()) (va_pbool_and
(va_codegen_success_Gctr_blocks128_body_1way alg) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_body0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_body0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 257 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Mod_cr0 ()) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 259 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_body_1way alg in_b out_b (va_get_reg 8 va_s) old_icb key round_keys
keys_b old_plain) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 261 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 262 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 263 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_QEmpty
(()))))))))
val va_lemma_Gctr_blocks128_1way_body0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_body0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) /\ va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_body0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_body0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_body0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 254 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 /\ (forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap)
(va_x_mem:vale_heap) (va_x_ok:bool) (va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64)
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7
(va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok (va_upd_mem va_x_mem (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM
/\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16 `op_Multiply`
va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb
(va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b
va_in_out_b \/ va_in_in_b == va_in_out_b) /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) va_in_in_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) va_in_out_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg
26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8
va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_body0 : va_old:va_state -> alg:algorithm -> va_in_in_b:buffer128
-> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32 ->
va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq quad32) ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_body0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb
va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_body0 (va_code_Gctr_blocks128_1way_body0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_body0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_body0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way_while0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_while0 alg =
(va_Block (va_CCons (va_While (va_cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (va_Block
(va_CCons (va_code_Gctr_blocks128_1way_body0 alg) (va_CNil ())))) (va_CNil ())))
val va_codegen_success_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_pbool | [] | Vale.AES.PPC64LE.GCTR.va_codegen_success_Gctr_blocks128_1way_while0 | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 81,
"end_line": 645,
"start_col": 2,
"start_line": 645
} |
Prims.Tot | val va_codegen_success_Gctr_blocks128_6way_body : alg:algorithm -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"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.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Gctr_blocks128_6way_body alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_Vadduwm (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 8))
(va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 10)) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 11)) (va_pbool_and
(va_codegen_success_Vadduwm (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 12))
(va_pbool_and (va_codegen_success_AESEncryptBlock_6way alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 14)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 15) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
27) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 16) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
28) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 17) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
29) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 18) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
30) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 19) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
31) Secret) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 15) (va_op_vec_opr_vec 1)) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 16) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 17) (va_op_vec_opr_vec 3))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 18)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 19) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Store_3blocks128_1 ()) (va_pbool_and (va_codegen_success_Store_3blocks128_2
()) (va_pbool_and (va_codegen_success_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 6)
(va_pbool_and (va_codegen_success_AddImm (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 3) (6
`op_Multiply` 16)) (va_pbool_and (va_codegen_success_AddImm (va_op_reg_opr_reg 7)
(va_op_reg_opr_reg 7) (6 `op_Multiply` 16)) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 13)) (va_ttrue
())))))))))))))))))))))))))) | val va_codegen_success_Gctr_blocks128_6way_body : alg:algorithm -> Tot va_pbool
let va_codegen_success_Gctr_blocks128_6way_body alg = | false | null | false | (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 8))
(va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 10))
(va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 11))
(va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 12))
(va_pbool_and (va_codegen_success_AESEncryptBlock_6way alg)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec 14)
(va_op_reg_opr_reg 3)
Secret)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec 15)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 27)
Secret)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec 16)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 28)
Secret)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 17)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 29)
Secret)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 18)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 30)
Secret)
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 19)
(va_op_reg_opr_reg 3)
(va_op_reg_opr_reg 31)
Secret)
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec
0)
(va_op_vec_opr_vec 14)
(va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec
1)
(va_op_vec_opr_vec 15)
(va_op_vec_opr_vec 1))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec
2)
(va_op_vec_opr_vec 16)
(va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 17)
(va_op_vec_opr_vec 3))
(va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 18)
(va_op_vec_opr_vec 4))
(va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 5
)
(va_op_vec_opr_vec 19
)
(va_op_vec_opr_vec 5
))
(va_pbool_and (va_codegen_success_Store_3blocks128_1
())
(va_pbool_and (va_codegen_success_Store_3blocks128_2
())
(va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg
8)
(va_op_reg_opr_reg
8)
6)
(va_pbool_and
(va_codegen_success_AddImm
(va_op_reg_opr_reg
3
)
(va_op_reg_opr_reg
3
)
(6
`op_Multiply`
16
))
(va_pbool_and
(va_codegen_success_AddImm
(
va_op_reg_opr_reg
7
)
(
va_op_reg_opr_reg
7
)
(
6
`op_Multiply`
16
)
)
(va_pbool_and
(
va_codegen_success_Vadduwm
(
va_op_vec_opr_vec
7
)
(
va_op_vec_opr_vec
7
)
(
va_op_vec_opr_vec
13
)
)
(
va_ttrue
()
)
))
))))))))))))
))))))))))) | {
"checked_file": "Vale.AES.PPC64LE.GCTR.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsVector.va_codegen_success_Vmr",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.InsVector.va_codegen_success_Vadduwm",
"Vale.AES.PPC64LE.AES.va_codegen_success_AESEncryptBlock_6way",
"Vale.PPC64LE.InsVector.va_codegen_success_Load128_byte16_buffer",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_codegen_success_Load128_byte16_buffer_index",
"Vale.PPC64LE.InsVector.va_codegen_success_Vxor",
"Vale.AES.PPC64LE.GCTR.va_codegen_success_Store_3blocks128_1",
"Vale.AES.PPC64LE.GCTR.va_codegen_success_Store_3blocks128_2",
"Vale.PPC64LE.InsBasic.va_codegen_success_AddImm",
"Prims.op_Multiply",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_body_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (plain_quads:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_body_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 152 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10536:Vale.AES.AES_common_s.algorithm) (key_10537:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10538:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10536 key_10537) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 6 va_s + count))) (fun _ -> let (ctr_enc:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 6 va_s + count) (va_get_mem_heaplet 1
va_s))) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 6 va_s + count))) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 154 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 155 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 157 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret in_b (va_get_reg 6 va_s + count)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret out_b (va_get_reg 6 va_s + count)) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 160 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 6
va_s + count) (va_get_mem_heaplet 1 va_s)) == ctr_enc) (let (va_arg24:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg23:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg22:Vale.Def.Types_s.quad32) = old_icb in let (va_arg21:Prims.nat) = va_get_reg 6 va_s +
count in let (va_arg20:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg19:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 162 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg18 va_arg19 va_arg20
va_arg21 va_arg22 va_arg23 va_arg24) (va_QEmpty (())))))))))))
val va_lemma_Gctr_blocks128_body_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> count:nat -> old_icb:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> plain_quads:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_body_1way alg) va_s0 /\ va_get_ok va_s0
/\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count `op_Multiply` 16
/\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_body_1way va_b0 va_s0 alg in_b out_b count old_icb key round_keys
keys_b plain_quads =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_body_1way va_mods alg in_b out_b count old_icb key round_keys
keys_b plain_quads in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_body_1way alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 110 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 148 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 149 column 132 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) (va_get_reg 6 va_sM + count + 1)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 150 column 126 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + count + 1) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (count:nat)
(old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (plain_quads:(seq
quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count
`op_Multiply` 16 /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7
va_s0) out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))
/\ (forall (va_x_mem:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM
/\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_body_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
count:nat -> old_icb:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
plain_quads:(seq quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_body_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count old_icb key round_keys keys_b
plain_quads va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_body_1way (va_code_Gctr_blocks128_body_1way alg)
va_s0 alg in_b out_b count old_icb key round_keys keys_b plain_quads in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_body_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_body_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec
0; va_Mod_reg 10; va_Mod_mem]) (va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads) (va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count
old_icb key round_keys keys_b plain_quads))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Gctr_blocks128_1way_body0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_body0 alg =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Gctr_blocks128_body_1way alg)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_CCons
(va_code_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_CCons (va_code_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_CNil ())))))))
val va_codegen_success_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_body0 alg =
(va_pbool_and (va_codegen_success_Mod_cr0 ()) (va_pbool_and
(va_codegen_success_Gctr_blocks128_body_1way alg) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_body0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_body0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 257 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Mod_cr0 ()) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 259 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_body_1way alg in_b out_b (va_get_reg 8 va_s) old_icb key round_keys
keys_b old_plain) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 261 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 262 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 263 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_QEmpty
(()))))))))
val va_lemma_Gctr_blocks128_1way_body0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_body0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) /\ va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_body0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_body0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_body0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 254 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 /\ (forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap)
(va_x_mem:vale_heap) (va_x_ok:bool) (va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64)
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7
(va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok (va_upd_mem va_x_mem (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM
/\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16 `op_Multiply`
va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb
(va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b
va_in_out_b \/ va_in_in_b == va_in_out_b) /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) va_in_in_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) va_in_out_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg
26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8
va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_body0 : va_old:va_state -> alg:algorithm -> va_in_in_b:buffer128
-> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32 ->
va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq quad32) ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_body0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb
va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_body0 (va_code_Gctr_blocks128_1way_body0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_body0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_body0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way_while0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_while0 alg =
(va_Block (va_CCons (va_While (va_cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (va_Block
(va_CCons (va_code_Gctr_blocks128_1way_body0 alg) (va_CNil ())))) (va_CNil ())))
val va_codegen_success_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_while0 alg =
(va_pbool_and (va_codegen_success_Gctr_blocks128_1way_body0 alg) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_while0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_while0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_qWhile va_mods (Cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (fun va_g -> qblock va_mods
(fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_1way_body0 va_old alg in_b key keys_b old_icb old_plain out_b
round_keys) (va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_get_ok va_s /\ (0 <= va_get_reg
8 va_s /\ va_get_reg 8 va_s <= va_get_reg 26 va_s) /\ va_get_reg 9 va_s == 16 `op_Multiply`
va_get_reg 8 va_s /\ va_get_vec 7 va_s == Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s
+ va_get_reg 8 va_s) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s) (va_get_reg 3 va_s) in_b
(va_get_reg 6 va_s) (va_get_reg 26 va_s) (va_get_mem_layout va_s) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s) (va_get_reg 7 va_s) out_b
(va_get_reg 6 va_s) (va_get_reg 26 va_s) (va_get_mem_layout va_s) Secret /\ va_get_reg 3 va_s +
16 `op_Multiply` va_get_reg 26 va_s < pow2_64 /\ va_get_reg 7 va_s + 16 `op_Multiply`
va_get_reg 26 va_s < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128
in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b /\ (va_get_reg 8
va_s =!= va_get_reg 26 va_s ==> Vale.AES.GCTR_BE.partial_seq_agreement old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) (va_get_reg 6 va_s + va_get_reg 8 va_s) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b)) /\ va_get_reg 6 va_s + va_get_reg 26 va_s < pow2_32 /\
aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s) (va_get_mem_heaplet 0 va_s)
(va_get_mem_layout va_s) /\ va_get_vec 3 va_s == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 1 0 0 0 /\ Vale.PPC64LE.Decls.modifies_buffer128 out_b
(va_get_mem_heaplet 1 va_old) (va_get_mem_heaplet 1 va_s) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s + va_get_reg 8 va_s) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) out_b)) key old_icb /\ (va_get_reg 6 va_s
+ va_get_reg 26 va_s == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) out_b ==
Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) out_b)) (fun (va_s:va_state) va_g ->
va_get_reg 26 va_s - va_get_reg 8 va_s) (())) (fun (va_s:va_state) va_g -> let va_g = () in
va_QEmpty (()))))
val va_lemma_Gctr_blocks128_1way_while0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_while0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM) /\ va_state_eq va_sM (va_update_vec 7 va_sM
(va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM (va_update_mem_heaplet 1 va_sM
(va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_while0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_while0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_while0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_while0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
(forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap) (va_x_mem:vale_heap) (va_x_ok:bool)
(va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0
(va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8 (va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok
(va_upd_mem va_x_mem (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in
va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\
va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_while0 : va_old:va_state -> alg:algorithm ->
va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32
-> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq quad32) ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_while0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_while0 (va_code_Gctr_blocks128_1way_while0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_while0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_while0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_while0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way alg =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 3) 1) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 4) 0) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3) 4) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_CCons
(va_code_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_CCons (va_code_Gctr_blocks128_1way_while0 alg)
(va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way alg =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 3) 1) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 4) 0) (va_pbool_and (va_codegen_success_Vsldoi
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3) 4) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_pbool_and
(va_codegen_success_Gctr_blocks128_1way_while0 alg) (va_ttrue ())))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (old_icb:quad32) (old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_blocks128_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 3) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 220 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 4) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 221 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 223 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 224 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 226 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_1way_while0 va_old_s alg in_b key keys_b old_icb old_plain out_b
round_keys) (va_QEmpty (())))))))))
val va_lemma_Gctr_blocks128_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> old_icb:quad32 -> old_plain:(seq quad32) -> key:(seq nat32)
-> round_keys:(seq quad32) -> keys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way alg) va_s0 /\ va_get_ok va_s0 /\
((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg
3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 +
va_get_reg 26 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
Vale.AES.GCTR_BE.partial_seq_agreement old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s0) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) key old_icb)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM)
old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) out_b)) key old_icb /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26 va_sM) /\ (va_get_reg 6
va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b
== Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 7 va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way va_b0 va_s0 alg in_b out_b old_icb old_plain key round_keys keys_b
=
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_ok;
va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_1way va_mods alg in_b out_b old_icb old_plain key round_keys
keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 212 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 215 column 118 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM) old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 216 column 51 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 217 column 79 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (old_icb:quad32)
(old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg
3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 +
va_get_reg 26 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
Vale.AES.GCTR_BE.partial_seq_agreement old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s0) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) key old_icb) /\ (forall
(va_x_mem:vale_heap) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_v0:quad32)
(va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v7:quad32) (va_x_cr0:cr0_t)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0
(va_upd_vec 7 va_x_v7 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM)
old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) out_b)) key old_icb /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26 va_sM) /\ (va_get_reg 6
va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b
== Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
old_icb:quad32 -> old_plain:(seq quad32) -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key
round_keys keys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_mem]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys keys_b va_s0
va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way (va_code_Gctr_blocks128_1way alg) va_s0 alg
in_b out_b old_icb old_plain key round_keys keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 7
va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0)))))))))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(old_icb:quad32) (old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_blocks128_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7;
va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg
8; va_Mod_mem]) (va_wp_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys
keys_b) (va_wpProof_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys keys_b))
#pop-options
//--
//-- Store_3blocks128_1
val va_code_Store_3blocks128_1 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Store_3blocks128_1 () =
(va_Block (va_CCons (va_code_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret) (va_CNil ())))))
val va_codegen_success_Store_3blocks128_1 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Store_3blocks128_1 () =
(va_pbool_and (va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Store_3blocks128_1 (va_mods:va_mods_t) (out_b:buffer128) : (va_quickCode unit
(va_code_Store_3blocks128_1 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 287 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret out_b (va_get_reg 8 va_s)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 288 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret out_b (va_get_reg 8 va_s + 1)) (fun
(va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 289 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret out_b (va_get_reg 8 va_s + 2)) (va_QEmpty
(()))))))
val va_lemma_Store_3blocks128_1 : va_b0:va_code -> va_s0:va_state -> out_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Store_3blocks128_1 ()) va_s0 /\ va_get_ok va_s0 /\
(va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 8 va_s0) (va_get_reg 6
va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 27 va_s0 == 1
`op_Multiply` 16 /\ va_get_reg 28 va_s0 == 2 `op_Multiply` 16)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))
[@"opaque_to_smt"]
let va_lemma_Store_3blocks128_1 va_b0 va_s0 out_b =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Store_3blocks128_1 va_mods out_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Store_3blocks128_1 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 282 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 284 column 74 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 285 column 74 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Store_3blocks128_1 (out_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 8 va_s0) (va_get_reg 6 va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0)
Secret /\ va_get_reg 27 va_s0 == 1 `op_Multiply` 16 /\ va_get_reg 28 va_s0 == 2 `op_Multiply`
16) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0) in va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)) ==> va_k va_sM (())))
val va_wpProof_Store_3blocks128_1 : out_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Store_3blocks128_1 out_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Store_3blocks128_1 ())
([va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Store_3blocks128_1 out_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Store_3blocks128_1 (va_code_Store_3blocks128_1 ()) va_s0 out_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Store_3blocks128_1 (out_b:buffer128) : (va_quickCode unit (va_code_Store_3blocks128_1
())) =
(va_QProc (va_code_Store_3blocks128_1 ()) ([va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Store_3blocks128_1 out_b) (va_wpProof_Store_3blocks128_1 out_b))
//--
//-- Store_3blocks128_2
val va_code_Store_3blocks128_2 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Store_3blocks128_2 () =
(va_Block (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 3) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret) (va_CNil ())))))
val va_codegen_success_Store_3blocks128_2 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Store_3blocks128_2 () =
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 3) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 4) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Store_3blocks128_2 (va_mods:va_mods_t) (out_b:buffer128) : (va_quickCode unit
(va_code_Store_3blocks128_2 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 3)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret out_b (va_get_reg 8 va_s + 3)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 314 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret out_b (va_get_reg 8 va_s + 4)) (fun
(va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 315 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret out_b (va_get_reg 8 va_s + 5)) (va_QEmpty
(()))))))
val va_lemma_Store_3blocks128_2 : va_b0:va_code -> va_s0:va_state -> out_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Store_3blocks128_2 ()) va_s0 /\ va_get_ok va_s0 /\
(va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 8 va_s0) (va_get_reg 6
va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 29 va_s0 == 3
`op_Multiply` 16 /\ va_get_reg 30 va_s0 == 4 `op_Multiply` 16 /\ va_get_reg 31 va_s0 == 5
`op_Multiply` 16)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM + 3) (va_get_reg 8 va_sM + 5) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 3) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 3 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 4) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 4 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 5) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 5 va_sM)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))
[@"opaque_to_smt"]
let va_lemma_Store_3blocks128_2 va_b0 va_s0 out_b =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Store_3blocks128_2 va_mods out_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Store_3blocks128_2 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 292 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 80 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM + 3) (va_get_reg 8 va_sM + 5)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 309 column 74 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 3) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 3 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 310 column 74 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 4) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 4 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 311 column 74 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 5) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 5 va_sM)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Store_3blocks128_2 (out_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 8 va_s0) (va_get_reg 6 va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0)
Secret /\ va_get_reg 29 va_s0 == 3 `op_Multiply` 16 /\ va_get_reg 30 va_s0 == 4 `op_Multiply`
16 /\ va_get_reg 31 va_s0 == 5 `op_Multiply` 16) /\ (forall (va_x_mem:vale_heap)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem
va_s0) in va_get_ok va_sM /\ (Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM + 3) (va_get_reg
8 va_sM + 5) /\ Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 3)
(va_get_mem_heaplet 1 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 3 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 4) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 4 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 5) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 5 va_sM)) ==> va_k va_sM (())))
val va_wpProof_Store_3blocks128_2 : out_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Store_3blocks128_2 out_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Store_3blocks128_2 ())
([va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Store_3blocks128_2 out_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Store_3blocks128_2 (va_code_Store_3blocks128_2 ()) va_s0 out_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Store_3blocks128_2 (out_b:buffer128) : (va_quickCode unit (va_code_Store_3blocks128_2
())) =
(va_QProc (va_code_Store_3blocks128_2 ()) ([va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Store_3blocks128_2 out_b) (va_wpProof_Store_3blocks128_2 out_b))
//--
//-- Gctr_blocks128_6way_body
val va_code_Gctr_blocks128_6way_body : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_6way_body alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 8))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 9))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 10))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 11))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 12))
(va_CCons (va_code_AESEncryptBlock_6way alg) (va_CCons (va_code_Load128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 14) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 15)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 27) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 16)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 28) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 17)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 29) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 18)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 30) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 19)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 31) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
0) (va_op_vec_opr_vec 14) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 15) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 16) (va_op_vec_opr_vec 2)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 17) (va_op_vec_opr_vec 3)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 18) (va_op_vec_opr_vec 4)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 19) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Store_3blocks128_1 ())
(va_CCons (va_code_Store_3blocks128_2 ()) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 8)
(va_op_reg_opr_reg 8) 6) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 3)
(6 `op_Multiply` 16)) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) (6
`op_Multiply` 16)) (va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 13)) (va_CNil ())))))))))))))))))))))))))))))))))
val va_codegen_success_Gctr_blocks128_6way_body : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Gctr_blocks128_6way_body : alg:algorithm -> Tot va_pbool | [] | Vale.AES.PPC64LE.GCTR.va_codegen_success_Gctr_blocks128_6way_body | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 32,
"end_line": 1421,
"start_col": 2,
"start_line": 1388
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.