file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
LowStar.RVector.fst
LowStar.RVector.assign_copy
val assign_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /\ rv_inv h1 rv /\ S.equal (as_seq h1 rv) (S.upd (as_seq h0 rv) (U32.v i) (Rgl?.r_repr rg h0 v))))
val assign_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /\ rv_inv h1 rv /\ S.equal (as_seq h1 rv) (S.upd (as_seq h0 rv) (U32.v i) (Rgl?.r_repr rg h0 v))))
let assign_copy #a #rst #rg cp rv i v = let hh0 = HST.get () in Cpy?.copy cp (Rgl?.state rg) v (V.index rv i); let hh1 = HST.get () in // Safety rv_inv_preserved_int #a #rst #rg rv i hh0 hh1; // Correctness forall_intro (move_requires (rs_loc_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i))); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i))); forall_intro (move_requires (r_sep_forall rg (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) hh0 hh1)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) ==> Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). S.index (as_seq_seq rg hh1 (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv))) k == S.index (as_seq_seq rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv))) k)
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 993, "start_col": 0, "start_line": 958 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx)) #reset-options "--z3rlimit 20" let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx) val alloc_rid: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc_rid #a #rst rg len rid = let vec = V.alloc_rid len (rg_dummy rg) rid in alloc_ #a #rst #rg vec len; V.loc_vector_within_included vec 0ul len; vec val alloc_reserve: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = 0ul /\ S.equal (as_seq h1 rv) S.empty /\ Set.equal (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ B.fresh_loc (V.loc_vector rv) h0 h1)) let alloc_reserve #a #rst rg len rid = V.alloc_reserve len (rg_dummy rg) rid val alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ HS.fresh_region (V.frameOf rv) h0 h1 /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc #a #rst rg len = let nrid = HST.new_region HS.root in alloc_rid rg len nrid val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) #reset-options "--z3rlimit 20" let insert #a #rst #rg rv v = let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; // Correctness assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) let insert_copy #a #rst #rg cp rv v = let hh0 = HST.get () in rv_elems_inv_live_region hh0 rv 0ul (V.size_of rv); let nrid = HST.new_region (V.frameOf rv) in let nv = rg_alloc rg nrid in let hh1 = HST.get () in Rgl?.r_sep rg v loc_none hh0 hh1; rv_inv_preserved rv loc_none hh0 hh1; as_seq_preserved rv loc_none hh0 hh1; Cpy?.copy cp (Rgl?.state rg) v nv; let hh2 = HST.get () in rv_loc_elems_each_disj hh2 rv 0ul (V.size_of rv) nrid; rv_inv_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; as_seq_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; insert rv nv val assign: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> // rv_inv h0 rv /\ rv_itself_inv h0 rv /\ rv_elems_inv h0 rv 0ul i /\ rv_elems_inv h0 rv (i + 1ul) (V.size_of rv) /\ elems_reg h0 rv /\ V.forall_ h0 rv 0ul i (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ V.forall_ h0 rv (i + 1ul) (V.size_of rv) (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv i (i + 1ul)) h0 h1 /\ rv_inv h1 rv /\ V.get h1 rv i == v /\ S.equal (as_seq h1 rv) (S.append (as_seq_sub h0 rv 0ul i) (S.cons (Rgl?.r_repr rg h0 v) (as_seq_sub h0 rv (i + 1ul) (V.size_of rv)))))) let assign #a #rst #rg rv i v = let hh0 = HST.get () in V.assign rv i v; let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v i); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i + 1) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v i) (V.loc_vector rv) hh0 hh1; rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1; Rgl?.r_sep rg v (V.loc_vector rv) hh0 hh1; // Correctness rs_loc_elems_parent_disj rg (V.as_seq hh1 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); as_seq_seq_preserved rg (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1 private val r_sep_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> p:loc -> h0:HS.mem -> h1:HS.mem -> v:a{rg_inv rg h0 v} -> Lemma (requires (loc_disjoint (loc_all_regions_from false (Rgl?.region_of rg v)) p /\ modifies p h0 h1)) (ensures (rg_inv rg h1 v /\ Rgl?.r_repr rg h0 v == Rgl?.r_repr rg h1 v)) private let r_sep_forall #a #rst rg p h0 h1 v = Rgl?.r_sep rg v p h0 h1 val assign_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /\ rv_inv h1 rv /\ S.equal (as_seq h1 rv)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cp: LowStar.RVector.copyable a rg -> rv: LowStar.RVector.rvector rg -> i: LowStar.Vector.uint32_t{i < LowStar.Vector.size_of rv} -> v: a -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.copyable", "LowStar.RVector.rvector", "LowStar.Vector.uint32_t", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Unsigned", "FStar.Integers.W32", "LowStar.Vector.size_of", "Prims._assert", "Prims.l_Forall", "FStar.Integers.nat", "Prims.op_AmpAmp", "Prims.op_disEquality", "Prims.int", "Prims.l_or", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt32.v", "Prims.eq2", "LowStar.Regional.__proj__Rgl__item__repr", "FStar.Seq.Base.index", "LowStar.RVector.as_seq_seq", "LowStar.Vector.as_seq", "Prims.unit", "LowStar.Regional.__proj__Rgl__item__r_repr", "Prims.l_imp", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.RVector.rs_loc_elem", "FStar.Classical.forall_intro", "LowStar.Regional.rg_inv", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_all_regions_from", "LowStar.Regional.__proj__Rgl__item__region_of", "LowStar.Monotonic.Buffer.modifies", "FStar.Classical.move_requires", "LowStar.RVector.r_sep_forall", "FStar.Integers.op_Less_Equals", "LowStar.RVector.rs_elems_reg", "LowStar.Vector.frameOf", "LowStar.RVector.rs_loc_elem_disj", "LowStar.RVector.rv_inv_preserved_int", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.RVector.__proj__Cpy__item__copy", "LowStar.Regional.__proj__Rgl__item__state", "LowStar.Vector.index" ]
[]
false
true
false
false
false
let assign_copy #a #rst #rg cp rv i v =
let hh0 = HST.get () in Cpy?.copy cp (Rgl?.state rg) v (V.index rv i); let hh1 = HST.get () in rv_inv_preserved_int #a #rst #rg rv i hh0 hh1; forall_intro (move_requires (rs_loc_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i))); assert (forall (k: nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) ); forall_intro (move_requires (r_sep_forall rg (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) hh0 hh1)); assert (forall (k: nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) ==> Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k: nat{k <> U32.v i && k < U32.v (V.size_of rv)}). Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k: nat{k <> U32.v i && k < U32.v (V.size_of rv)}). S.index (as_seq_seq rg hh1 (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv))) k == S.index (as_seq_seq rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv))) k)
false
LowStar.RVector.fst
LowStar.RVector.free_elems_from
val free_elems_from: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv idx (V.size_of rv) /\ rv_elems_reg h0 rv idx (V.size_of rv))) (ensures (fun h0 _ h1 -> modifies (rv_loc_elems h0 rv idx (V.size_of rv)) h0 h1))
val free_elems_from: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv idx (V.size_of rv) /\ rv_elems_reg h0 rv idx (V.size_of rv))) (ensures (fun h0 _ h1 -> modifies (rv_loc_elems h0 rv idx (V.size_of rv)) h0 h1))
let rec free_elems_from #a #rst #rg rv idx = let hh0 = HST.get () in rs_loc_elems_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v idx) (U32.v (V.size_of rv)) (U32.v idx+1) (U32.v (V.size_of rv)) (U32.v idx); rg_free rg (V.index rv idx); let hh1 = HST.get () in rv_elems_inv_preserved rv (idx+1ul) (V.size_of rv) (rv_loc_elem hh0 rv idx) hh0 hh1; if idx + 1ul < V.size_of rv then begin free_elems_from rv (idx + 1ul); rs_loc_elems_rec_inverse rg (V.as_seq hh0 rv) (U32.v idx) (U32.v (V.size_of rv)) end
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 1110, "start_col": 0, "start_line": 1091 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx)) #reset-options "--z3rlimit 20" let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx) val alloc_rid: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc_rid #a #rst rg len rid = let vec = V.alloc_rid len (rg_dummy rg) rid in alloc_ #a #rst #rg vec len; V.loc_vector_within_included vec 0ul len; vec val alloc_reserve: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = 0ul /\ S.equal (as_seq h1 rv) S.empty /\ Set.equal (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ B.fresh_loc (V.loc_vector rv) h0 h1)) let alloc_reserve #a #rst rg len rid = V.alloc_reserve len (rg_dummy rg) rid val alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ HS.fresh_region (V.frameOf rv) h0 h1 /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc #a #rst rg len = let nrid = HST.new_region HS.root in alloc_rid rg len nrid val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) #reset-options "--z3rlimit 20" let insert #a #rst #rg rv v = let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; // Correctness assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) let insert_copy #a #rst #rg cp rv v = let hh0 = HST.get () in rv_elems_inv_live_region hh0 rv 0ul (V.size_of rv); let nrid = HST.new_region (V.frameOf rv) in let nv = rg_alloc rg nrid in let hh1 = HST.get () in Rgl?.r_sep rg v loc_none hh0 hh1; rv_inv_preserved rv loc_none hh0 hh1; as_seq_preserved rv loc_none hh0 hh1; Cpy?.copy cp (Rgl?.state rg) v nv; let hh2 = HST.get () in rv_loc_elems_each_disj hh2 rv 0ul (V.size_of rv) nrid; rv_inv_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; as_seq_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; insert rv nv val assign: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> // rv_inv h0 rv /\ rv_itself_inv h0 rv /\ rv_elems_inv h0 rv 0ul i /\ rv_elems_inv h0 rv (i + 1ul) (V.size_of rv) /\ elems_reg h0 rv /\ V.forall_ h0 rv 0ul i (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ V.forall_ h0 rv (i + 1ul) (V.size_of rv) (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv i (i + 1ul)) h0 h1 /\ rv_inv h1 rv /\ V.get h1 rv i == v /\ S.equal (as_seq h1 rv) (S.append (as_seq_sub h0 rv 0ul i) (S.cons (Rgl?.r_repr rg h0 v) (as_seq_sub h0 rv (i + 1ul) (V.size_of rv)))))) let assign #a #rst #rg rv i v = let hh0 = HST.get () in V.assign rv i v; let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v i); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i + 1) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v i) (V.loc_vector rv) hh0 hh1; rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1; Rgl?.r_sep rg v (V.loc_vector rv) hh0 hh1; // Correctness rs_loc_elems_parent_disj rg (V.as_seq hh1 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); as_seq_seq_preserved rg (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1 private val r_sep_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> p:loc -> h0:HS.mem -> h1:HS.mem -> v:a{rg_inv rg h0 v} -> Lemma (requires (loc_disjoint (loc_all_regions_from false (Rgl?.region_of rg v)) p /\ modifies p h0 h1)) (ensures (rg_inv rg h1 v /\ Rgl?.r_repr rg h0 v == Rgl?.r_repr rg h1 v)) private let r_sep_forall #a #rst rg p h0 h1 v = Rgl?.r_sep rg v p h0 h1 val assign_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /\ rv_inv h1 rv /\ S.equal (as_seq h1 rv) (S.upd (as_seq h0 rv) (U32.v i) (Rgl?.r_repr rg h0 v)))) let assign_copy #a #rst #rg cp rv i v = let hh0 = HST.get () in Cpy?.copy cp (Rgl?.state rg) v (V.index rv i); let hh1 = HST.get () in // Safety rv_inv_preserved_int #a #rst #rg rv i hh0 hh1; // Correctness forall_intro (move_requires (rs_loc_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i))); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i))); forall_intro (move_requires (r_sep_forall rg (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) hh0 hh1)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) ==> Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). S.index (as_seq_seq rg hh1 (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv))) k == S.index (as_seq_seq rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv))) k) val free_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv 0ul (idx + 1ul) /\ rv_elems_reg h0 rv 0ul (idx + 1ul))) (ensures (fun h0 _ h1 -> modifies (rv_loc_elems h0 rv 0ul (idx + 1ul)) h0 h1)) let rec free_elems #a #rst #rg rv idx = let hh0 = HST.get () in rg_free rg (V.index rv idx); let hh1 = HST.get () in rs_loc_elems_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v idx + 1) 0 (U32.v idx) (U32.v idx); rv_elems_inv_preserved rv 0ul idx (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v idx)) hh0 hh1; if idx <> 0ul then free_elems rv (idx - 1ul) val flush: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i <= V.size_of rv} -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv)) (ensures (fun h0 frv h1 -> V.size_of frv = V.size_of rv - i /\ V.frameOf rv = V.frameOf frv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 frv /\ S.equal (as_seq h1 frv) (S.slice (as_seq h0 rv) (U32.v i) (U32.v (V.size_of rv))))) #reset-options "--z3rlimit 40" let flush #a #rst #rg rv i = let hh0 = HST.get () in (if i = 0ul then () else free_elems rv (i - 1ul)); rv_loc_elems_included hh0 rv 0ul i; let hh1 = HST.get () in assert (modifies (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) hh0 hh1); let frv = V.flush rv (rg_dummy rg) i in let hh2 = HST.get () in assert (modifies (loc_region_only false (V.frameOf rv)) hh1 hh2); // Safety rs_loc_elems_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i) (U32.v (V.size_of rv)); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)) (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) (loc_region_only false (V.frameOf rv))) hh0 hh2; assert (rv_inv #a #rst #rg hh2 frv); // Correctness as_seq_seq_preserved rg (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)) (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) (loc_region_only false (V.frameOf rv))) hh0 hh2; as_seq_seq_slice rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (U32.v i) (U32.v (V.size_of rv)); assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))) (as_seq_seq rg hh2 (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)))); as_seq_seq_eq rg hh2 (V.as_seq hh0 rv) (V.as_seq hh2 frv) (U32.v i) (U32.v (V.size_of rv)) 0 (U32.v (V.size_of frv)); assert (S.equal (as_seq_seq rg hh2 (V.as_seq hh2 frv) 0 (U32.v (V.size_of frv))) (as_seq_seq rg hh2 (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)))); assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))) (as_seq hh2 frv)); frv val free_elems_from: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv idx (V.size_of rv) /\ rv_elems_reg h0 rv idx (V.size_of rv))) (ensures (fun h0 _ h1 ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rv: LowStar.RVector.rvector rg -> idx: LowStar.Vector.uint32_t{idx < LowStar.Vector.size_of rv} -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Vector.uint32_t", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Unsigned", "FStar.Integers.W32", "LowStar.Vector.size_of", "FStar.Integers.op_Plus", "FStar.UInt32.__uint_to_t", "LowStar.RVector.rs_loc_elems_rec_inverse", "LowStar.Vector.as_seq", "FStar.UInt32.v", "Prims.unit", "LowStar.RVector.free_elems_from", "Prims.bool", "LowStar.RVector.rv_elems_inv_preserved", "LowStar.RVector.rv_loc_elem", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Regional.rg_free", "LowStar.Vector.index", "LowStar.RVector.rs_loc_elems_elem_disj", "LowStar.Vector.frameOf", "FStar.Integers.Signed", "FStar.Integers.Winfinite" ]
[ "recursion" ]
false
true
false
false
false
let rec free_elems_from #a #rst #rg rv idx =
let hh0 = HST.get () in rs_loc_elems_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v idx) (U32.v (V.size_of rv)) (U32.v idx + 1) (U32.v (V.size_of rv)) (U32.v idx); rg_free rg (V.index rv idx); let hh1 = HST.get () in rv_elems_inv_preserved rv (idx + 1ul) (V.size_of rv) (rv_loc_elem hh0 rv idx) hh0 hh1; if idx + 1ul < V.size_of rv then (free_elems_from rv (idx + 1ul); rs_loc_elems_rec_inverse rg (V.as_seq hh0 rv) (U32.v idx) (U32.v (V.size_of rv)))
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_unit
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_unit:printable unit
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_unit:printable unit
instance printable_unit : printable unit = { to_string = (fun _ -> "()") }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 34, "start_col": 0, "start_line": 31 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable Prims.unit
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "Prims.unit", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_unit:printable unit =
{ to_string = (fun _ -> "()") }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_nat
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_nat:printable nat
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_nat:printable nat
instance printable_nat : printable nat = { to_string = Prims.string_of_int }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 44, "start_col": 0, "start_line": 41 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable Prims.nat
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "Prims.nat", "Prims.string_of_int" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_nat:printable nat =
{ to_string = Prims.string_of_int }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_bool
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_bool:printable bool
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_bool:printable bool
instance printable_bool : printable bool = { to_string = Prims.string_of_bool }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 39, "start_col": 0, "start_line": 36 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "Prims.bool", "Prims.string_of_bool" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_bool:printable bool =
{ to_string = Prims.string_of_bool }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_ref
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_ref (#a #p: _) (d: printable a) : printable (x: a{p x})
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_ref (#a #p: _) (d: printable a) : printable (x: a{p x})
instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 57, "start_col": 0, "start_line": 54 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat],
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: FStar.Class.Printable.printable a -> FStar.Class.Printable.printable (x: a{p x})
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Class.Printable.__proj__Mkprintable__item__to_string" ]
[]
false
false
false
false
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_ref #a #p (d: printable a) : printable (x: a{p x}) =
{ to_string = d.to_string }
false
LowStar.RVector.fst
LowStar.RVector.free_elems
val free_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv 0ul (idx + 1ul) /\ rv_elems_reg h0 rv 0ul (idx + 1ul))) (ensures (fun h0 _ h1 -> modifies (rv_loc_elems h0 rv 0ul (idx + 1ul)) h0 h1))
val free_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv 0ul (idx + 1ul) /\ rv_elems_reg h0 rv 0ul (idx + 1ul))) (ensures (fun h0 _ h1 -> modifies (rv_loc_elems h0 rv 0ul (idx + 1ul)) h0 h1))
let rec free_elems #a #rst #rg rv idx = let hh0 = HST.get () in rg_free rg (V.index rv idx); let hh1 = HST.get () in rs_loc_elems_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v idx + 1) 0 (U32.v idx) (U32.v idx); rv_elems_inv_preserved rv 0ul idx (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v idx)) hh0 hh1; if idx <> 0ul then free_elems rv (idx - 1ul)
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 1017, "start_col": 0, "start_line": 1005 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx)) #reset-options "--z3rlimit 20" let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx) val alloc_rid: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc_rid #a #rst rg len rid = let vec = V.alloc_rid len (rg_dummy rg) rid in alloc_ #a #rst #rg vec len; V.loc_vector_within_included vec 0ul len; vec val alloc_reserve: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = 0ul /\ S.equal (as_seq h1 rv) S.empty /\ Set.equal (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ B.fresh_loc (V.loc_vector rv) h0 h1)) let alloc_reserve #a #rst rg len rid = V.alloc_reserve len (rg_dummy rg) rid val alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ HS.fresh_region (V.frameOf rv) h0 h1 /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc #a #rst rg len = let nrid = HST.new_region HS.root in alloc_rid rg len nrid val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) #reset-options "--z3rlimit 20" let insert #a #rst #rg rv v = let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; // Correctness assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) let insert_copy #a #rst #rg cp rv v = let hh0 = HST.get () in rv_elems_inv_live_region hh0 rv 0ul (V.size_of rv); let nrid = HST.new_region (V.frameOf rv) in let nv = rg_alloc rg nrid in let hh1 = HST.get () in Rgl?.r_sep rg v loc_none hh0 hh1; rv_inv_preserved rv loc_none hh0 hh1; as_seq_preserved rv loc_none hh0 hh1; Cpy?.copy cp (Rgl?.state rg) v nv; let hh2 = HST.get () in rv_loc_elems_each_disj hh2 rv 0ul (V.size_of rv) nrid; rv_inv_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; as_seq_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; insert rv nv val assign: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> // rv_inv h0 rv /\ rv_itself_inv h0 rv /\ rv_elems_inv h0 rv 0ul i /\ rv_elems_inv h0 rv (i + 1ul) (V.size_of rv) /\ elems_reg h0 rv /\ V.forall_ h0 rv 0ul i (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ V.forall_ h0 rv (i + 1ul) (V.size_of rv) (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv i (i + 1ul)) h0 h1 /\ rv_inv h1 rv /\ V.get h1 rv i == v /\ S.equal (as_seq h1 rv) (S.append (as_seq_sub h0 rv 0ul i) (S.cons (Rgl?.r_repr rg h0 v) (as_seq_sub h0 rv (i + 1ul) (V.size_of rv)))))) let assign #a #rst #rg rv i v = let hh0 = HST.get () in V.assign rv i v; let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v i); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i + 1) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v i) (V.loc_vector rv) hh0 hh1; rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1; Rgl?.r_sep rg v (V.loc_vector rv) hh0 hh1; // Correctness rs_loc_elems_parent_disj rg (V.as_seq hh1 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); as_seq_seq_preserved rg (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1 private val r_sep_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> p:loc -> h0:HS.mem -> h1:HS.mem -> v:a{rg_inv rg h0 v} -> Lemma (requires (loc_disjoint (loc_all_regions_from false (Rgl?.region_of rg v)) p /\ modifies p h0 h1)) (ensures (rg_inv rg h1 v /\ Rgl?.r_repr rg h0 v == Rgl?.r_repr rg h1 v)) private let r_sep_forall #a #rst rg p h0 h1 v = Rgl?.r_sep rg v p h0 h1 val assign_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /\ rv_inv h1 rv /\ S.equal (as_seq h1 rv) (S.upd (as_seq h0 rv) (U32.v i) (Rgl?.r_repr rg h0 v)))) let assign_copy #a #rst #rg cp rv i v = let hh0 = HST.get () in Cpy?.copy cp (Rgl?.state rg) v (V.index rv i); let hh1 = HST.get () in // Safety rv_inv_preserved_int #a #rst #rg rv i hh0 hh1; // Correctness forall_intro (move_requires (rs_loc_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i))); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i))); forall_intro (move_requires (r_sep_forall rg (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) hh0 hh1)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) ==> Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). S.index (as_seq_seq rg hh1 (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv))) k == S.index (as_seq_seq rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv))) k) val free_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv 0ul (idx + 1ul) /\ rv_elems_reg h0 rv 0ul (idx + 1ul))) (ensures (fun h0 _ h1 ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rv: LowStar.RVector.rvector rg -> idx: LowStar.Vector.uint32_t{idx < LowStar.Vector.size_of rv} -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Vector.uint32_t", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Unsigned", "FStar.Integers.W32", "LowStar.Vector.size_of", "Prims.op_disEquality", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "LowStar.RVector.free_elems", "FStar.Integers.op_Subtraction", "Prims.unit", "Prims.bool", "LowStar.RVector.rv_elems_inv_preserved", "LowStar.RVector.rs_loc_elem", "LowStar.Vector.as_seq", "FStar.UInt32.v", "LowStar.RVector.rs_loc_elems_elem_disj", "LowStar.Vector.frameOf", "FStar.Integers.op_Plus", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Regional.rg_free", "LowStar.Vector.index" ]
[ "recursion" ]
false
true
false
false
false
let rec free_elems #a #rst #rg rv idx =
let hh0 = HST.get () in rg_free rg (V.index rv idx); let hh1 = HST.get () in rs_loc_elems_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v idx + 1) 0 (U32.v idx) (U32.v idx); rv_elems_inv_preserved rv 0ul idx (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v idx)) hh0 hh1; if idx <> 0ul then free_elems rv (idx - 1ul)
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_string
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_string:printable string
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_string:printable string
instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 67, "start_col": 0, "start_line": 64 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable Prims.string
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "Prims.string", "Prims.op_Hat" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_string:printable string =
{ to_string = fun x -> "\"" ^ x ^ "\"" }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_list
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_list (#a: Type) (x: printable a) : printable (list a)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_list (#a: Type) (x: printable a) : printable (list a)
instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 62, "start_col": 0, "start_line": 59 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Class.Printable.printable a -> FStar.Class.Printable.printable (Prims.list a)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "Prims.list", "Prims.op_Hat", "FStar.String.concat", "FStar.List.Tot.Base.map", "Prims.string", "FStar.Class.Printable.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_list (#a: Type) (x: printable a) : printable (list a) =
{ to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_char
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_char:printable FStar.Char.char
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_char:printable FStar.Char.char
instance printable_char : printable FStar.Char.char = { to_string = string_of_char }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 86, "start_col": 0, "start_line": 83 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.Char.char
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.Char.char", "FStar.String.string_of_char" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_char:printable FStar.Char.char =
{ to_string = string_of_char }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_int
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int:printable int
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int:printable int
instance printable_int : printable int = { to_string = Prims.string_of_int }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 49, "start_col": 0, "start_line": 46 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable Prims.int
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "Prims.int", "Prims.string_of_int" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_int:printable int =
{ to_string = Prims.string_of_int }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_int8
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int8:printable FStar.Int8.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int8:printable FStar.Int8.t
instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 109, "start_col": 0, "start_line": 106 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.Int8.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.Int8.t", "FStar.Int8.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_int8:printable FStar.Int8.t =
{ to_string = FStar.Int8.to_string }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_int16
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int16:printable FStar.Int16.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int16:printable FStar.Int16.t
instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 119, "start_col": 0, "start_line": 116 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.Int16.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.Int16.t", "FStar.Int16.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_int16:printable FStar.Int16.t =
{ to_string = FStar.Int16.to_string }
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_quick_ReduceMul128_LE
val va_quick_ReduceMul128_LE (a b: poly) : (va_quickCode unit (va_code_ReduceMul128_LE ()))
val va_quick_ReduceMul128_LE (a b: poly) : (va_quickCode unit (va_code_ReduceMul128_LE ()))
let va_quick_ReduceMul128_LE (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (va_QProc (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) (va_wp_ReduceMul128_LE a b) (va_wpProof_ReduceMul128_LE a b))
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 197, "start_col": 0, "start_line": 194 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) = (va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0) //-- //-- ReduceMul128_LE val va_code_ReduceMul128_LE : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_ReduceMul128_LE () = (va_Block (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CCons (va_code_ReduceMulRev128 ()) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CNil ()))))) val va_codegen_success_ReduceMul128_LE : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_ReduceMul128_LE () = (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_ReduceMulRev128 ()) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_ReduceMul128_LE (va_mods:va_mods_t) (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (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 104 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMulRev128 a b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 106 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QEmpty (())))))) val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_ReduceMul128_LE va_b0 va_s0 a b = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok] in let va_qc = va_qcode_ReduceMul128_LE va_mods a b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceMul128_LE ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 87 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 102 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_ReduceMul128_LE (a:poly) (b:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) . let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) ==> va_k va_sM (()))) val va_wpProof_ReduceMul128_LE : a:poly -> b:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_ReduceMul128_LE a b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_ReduceMul128_LE a b va_s0 va_k = let (va_sM, va_f0) = va_lemma_ReduceMul128_LE (va_code_ReduceMul128_LE ()) va_s0 a b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Math.Poly2_s.poly -> b: Vale.Math.Poly2_s.poly -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.GHash.va_code_ReduceMul128_LE ())
Prims.Tot
[ "total" ]
[]
[ "Vale.Math.Poly2_s.poly", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.AES.X64.GHash.va_code_ReduceMul128_LE", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR12", "Vale.X64.QuickCode.va_Mod_flags", "Prims.Nil", "Vale.AES.X64.GHash.va_wp_ReduceMul128_LE", "Vale.AES.X64.GHash.va_wpProof_ReduceMul128_LE", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_ReduceMul128_LE (a b: poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) =
(va_QProc (va_code_ReduceMul128_LE ()) ([ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags ]) (va_wp_ReduceMul128_LE a b) (va_wpProof_ReduceMul128_LE a b))
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_byte
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_byte:printable FStar.UInt8.byte
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_byte:printable FStar.UInt8.byte
instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 104, "start_col": 0, "start_line": 101 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.UInt8.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.UInt8.t", "FStar.UInt8.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_byte:printable FStar.UInt8.byte =
{ to_string = FStar.UInt8.to_string }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_uint8
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint8:printable FStar.UInt8.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint8:printable FStar.UInt8.t
instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 114, "start_col": 0, "start_line": 111 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.UInt8.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.UInt8.t", "FStar.UInt8.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_uint8:printable FStar.UInt8.t =
{ to_string = FStar.UInt8.to_string }
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_lemma_Compute_Y0
val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))))
val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))))
let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 70, "start_col": 0, "start_line": 59 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.GHash.va_code_Compute_Y0", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.X64.Decls.va_get_xmm", "Vale.Def.Words_s.Mkfour", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.GHash.va_qcode_Compute_Y0" ]
[]
false
false
false
false
false
let va_lemma_Compute_Y0 va_b0 va_s0 =
let va_mods:va_mods_t = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_uint16
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint16:printable FStar.UInt16.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint16:printable FStar.UInt16.t
instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 124, "start_col": 0, "start_line": 121 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.UInt16.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.UInt16.t", "FStar.UInt16.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_uint16:printable FStar.UInt16.t =
{ to_string = FStar.UInt16.to_string }
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_quick_Compute_Y0
val va_quick_Compute_Y0: Prims.unit -> (va_quickCode unit (va_code_Compute_Y0 ()))
val va_quick_Compute_Y0: Prims.unit -> (va_quickCode unit (va_code_Compute_Y0 ()))
let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) = (va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0)
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 97, "start_col": 0, "start_line": 95 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.GHash.va_code_Compute_Y0 ())
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "Vale.X64.QuickCode.va_QProc", "Vale.AES.X64.GHash.va_code_Compute_Y0", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Prims.Nil", "Vale.AES.X64.GHash.va_wp_Compute_Y0", "Vale.AES.X64.GHash.va_wpProof_Compute_Y0", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) =
(va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0)
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_qcode_Compute_Y0
val va_qcode_Compute_Y0 (va_mods: va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ()))
val va_qcode_Compute_Y0 (va_mods: va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ()))
let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (())))))
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 48, "start_col": 0, "start_line": 42 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ()))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_mods: Vale.X64.QuickCode.va_mods_t -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.GHash.va_code_Compute_Y0 ())
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsVector.va_code_Pxor", "Vale.X64.Decls.va_op_xmm_xmm", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsVector.va_quick_Pxor", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Vale.Def.Types_s.quad32", "Prims.eq2", "Vale.Def.Words_s.four", "Vale.Def.Words_s.nat32", "Vale.Def.Types_s.quad32_xor", "Vale.Def.Words_s.Mkfour", "Vale.Arch.Types.lemma_quad32_xor", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.GHash.va_code_Compute_Y0" ]
[]
false
false
false
false
false
let va_qcode_Compute_Y0 (va_mods: va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) =
(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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_: unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (())))))
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_int64
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int64:printable FStar.Int64.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int64:printable FStar.Int64.t
instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 139, "start_col": 0, "start_line": 136 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.Int64.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.Int64.t", "FStar.Int64.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_int64:printable FStar.Int64.t =
{ to_string = FStar.Int64.to_string }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_int32
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int32:printable FStar.Int32.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_int32:printable FStar.Int32.t
instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 129, "start_col": 0, "start_line": 126 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.Int32.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.Int32.t", "FStar.Int32.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_int32:printable FStar.Int32.t =
{ to_string = FStar.Int32.to_string }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_uint64
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint64:printable FStar.UInt64.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint64:printable FStar.UInt64.t
instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 144, "start_col": 0, "start_line": 141 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.UInt64.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.UInt64.t", "FStar.UInt64.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_uint64:printable FStar.UInt64.t =
{ to_string = FStar.UInt64.to_string }
false
LowStar.RVector.fst
LowStar.RVector.shrink
val shrink: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> new_size:uint32_t{new_size <= V.size_of rv} -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv)) (ensures (fun h0 frv h1 -> V.size_of frv = new_size /\ V.frameOf rv = V.frameOf frv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 frv /\ S.equal (as_seq h1 frv) (S.slice (as_seq h0 rv) 0 (U32.v new_size))))
val shrink: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> new_size:uint32_t{new_size <= V.size_of rv} -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv)) (ensures (fun h0 frv h1 -> V.size_of frv = new_size /\ V.frameOf rv = V.frameOf frv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 frv /\ S.equal (as_seq h1 frv) (S.slice (as_seq h0 rv) 0 (U32.v new_size))))
let shrink #a #rst #rg rv new_size = let size = V.size_of rv in [@@inline_let] let sz = U32.v size in [@@inline_let] let nsz = U32.v new_size in let hh0 = HST.get () in if new_size >= size then rv else begin free_elems_from rv new_size; rv_loc_elems_included hh0 rv new_size size; let hh1 = HST.get () in assert (modifies (rs_loc_elems rg (V.as_seq hh0 rv) nsz sz) hh0 hh1); let frv = V.shrink rv new_size in let hh2 = HST.get () in assert (modifies (loc_region_only false (V.frameOf rv)) hh1 hh2); // Safety rs_loc_elems_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 sz 0 nsz nsz sz; rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 nsz; rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 nsz (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) nsz sz) (loc_region_only false (V.frameOf rv))) hh0 hh2; assert (rv_inv #a #rst #rg hh2 frv); // Correctness as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 nsz (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) nsz sz) (loc_region_only false (V.frameOf rv))) hh0 hh2; as_seq_seq_slice rg hh0 (V.as_seq hh0 rv) 0 sz 0 nsz; assert (S.equal (S.slice (as_seq hh0 rv) 0 nsz) (as_seq_seq rg hh2 (V.as_seq hh0 rv) 0 nsz)); as_seq_seq_eq rg hh2 (V.as_seq hh0 rv) (V.as_seq hh2 frv) 0 nsz 0 nsz; assert (S.equal (as_seq_seq rg hh2 (V.as_seq hh2 frv) 0 nsz) (as_seq_seq rg hh2 (V.as_seq hh0 rv) 0 nsz)); assert (S.equal (S.slice (as_seq hh0 rv) 0 nsz) (as_seq hh2 frv)); frv end
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 1171, "start_col": 0, "start_line": 1125 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx)) #reset-options "--z3rlimit 20" let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx) val alloc_rid: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc_rid #a #rst rg len rid = let vec = V.alloc_rid len (rg_dummy rg) rid in alloc_ #a #rst #rg vec len; V.loc_vector_within_included vec 0ul len; vec val alloc_reserve: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = 0ul /\ S.equal (as_seq h1 rv) S.empty /\ Set.equal (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ B.fresh_loc (V.loc_vector rv) h0 h1)) let alloc_reserve #a #rst rg len rid = V.alloc_reserve len (rg_dummy rg) rid val alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ HS.fresh_region (V.frameOf rv) h0 h1 /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc #a #rst rg len = let nrid = HST.new_region HS.root in alloc_rid rg len nrid val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) #reset-options "--z3rlimit 20" let insert #a #rst #rg rv v = let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; // Correctness assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) let insert_copy #a #rst #rg cp rv v = let hh0 = HST.get () in rv_elems_inv_live_region hh0 rv 0ul (V.size_of rv); let nrid = HST.new_region (V.frameOf rv) in let nv = rg_alloc rg nrid in let hh1 = HST.get () in Rgl?.r_sep rg v loc_none hh0 hh1; rv_inv_preserved rv loc_none hh0 hh1; as_seq_preserved rv loc_none hh0 hh1; Cpy?.copy cp (Rgl?.state rg) v nv; let hh2 = HST.get () in rv_loc_elems_each_disj hh2 rv 0ul (V.size_of rv) nrid; rv_inv_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; as_seq_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; insert rv nv val assign: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> // rv_inv h0 rv /\ rv_itself_inv h0 rv /\ rv_elems_inv h0 rv 0ul i /\ rv_elems_inv h0 rv (i + 1ul) (V.size_of rv) /\ elems_reg h0 rv /\ V.forall_ h0 rv 0ul i (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ V.forall_ h0 rv (i + 1ul) (V.size_of rv) (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv i (i + 1ul)) h0 h1 /\ rv_inv h1 rv /\ V.get h1 rv i == v /\ S.equal (as_seq h1 rv) (S.append (as_seq_sub h0 rv 0ul i) (S.cons (Rgl?.r_repr rg h0 v) (as_seq_sub h0 rv (i + 1ul) (V.size_of rv)))))) let assign #a #rst #rg rv i v = let hh0 = HST.get () in V.assign rv i v; let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v i); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i + 1) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v i) (V.loc_vector rv) hh0 hh1; rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1; Rgl?.r_sep rg v (V.loc_vector rv) hh0 hh1; // Correctness rs_loc_elems_parent_disj rg (V.as_seq hh1 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); as_seq_seq_preserved rg (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1 private val r_sep_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> p:loc -> h0:HS.mem -> h1:HS.mem -> v:a{rg_inv rg h0 v} -> Lemma (requires (loc_disjoint (loc_all_regions_from false (Rgl?.region_of rg v)) p /\ modifies p h0 h1)) (ensures (rg_inv rg h1 v /\ Rgl?.r_repr rg h0 v == Rgl?.r_repr rg h1 v)) private let r_sep_forall #a #rst rg p h0 h1 v = Rgl?.r_sep rg v p h0 h1 val assign_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /\ rv_inv h1 rv /\ S.equal (as_seq h1 rv) (S.upd (as_seq h0 rv) (U32.v i) (Rgl?.r_repr rg h0 v)))) let assign_copy #a #rst #rg cp rv i v = let hh0 = HST.get () in Cpy?.copy cp (Rgl?.state rg) v (V.index rv i); let hh1 = HST.get () in // Safety rv_inv_preserved_int #a #rst #rg rv i hh0 hh1; // Correctness forall_intro (move_requires (rs_loc_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i))); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i))); forall_intro (move_requires (r_sep_forall rg (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) hh0 hh1)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). loc_disjoint (rs_loc_elem rg (V.as_seq hh0 rv) k) (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v i)) ==> Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). Rgl?.r_repr rg hh1 (S.index (V.as_seq hh1 rv) k) == Rgl?.r_repr rg hh0 (S.index (V.as_seq hh0 rv) k)); assert (forall (k:nat{k <> U32.v i && k < U32.v (V.size_of rv)}). S.index (as_seq_seq rg hh1 (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv))) k == S.index (as_seq_seq rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv))) k) val free_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv 0ul (idx + 1ul) /\ rv_elems_reg h0 rv 0ul (idx + 1ul))) (ensures (fun h0 _ h1 -> modifies (rv_loc_elems h0 rv 0ul (idx + 1ul)) h0 h1)) let rec free_elems #a #rst #rg rv idx = let hh0 = HST.get () in rg_free rg (V.index rv idx); let hh1 = HST.get () in rs_loc_elems_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v idx + 1) 0 (U32.v idx) (U32.v idx); rv_elems_inv_preserved rv 0ul idx (rs_loc_elem rg (V.as_seq hh0 rv) (U32.v idx)) hh0 hh1; if idx <> 0ul then free_elems rv (idx - 1ul) val flush: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i <= V.size_of rv} -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv)) (ensures (fun h0 frv h1 -> V.size_of frv = V.size_of rv - i /\ V.frameOf rv = V.frameOf frv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 frv /\ S.equal (as_seq h1 frv) (S.slice (as_seq h0 rv) (U32.v i) (U32.v (V.size_of rv))))) #reset-options "--z3rlimit 40" let flush #a #rst #rg rv i = let hh0 = HST.get () in (if i = 0ul then () else free_elems rv (i - 1ul)); rv_loc_elems_included hh0 rv 0ul i; let hh1 = HST.get () in assert (modifies (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) hh0 hh1); let frv = V.flush rv (rg_dummy rg) i in let hh2 = HST.get () in assert (modifies (loc_region_only false (V.frameOf rv)) hh1 hh2); // Safety rs_loc_elems_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i) (U32.v (V.size_of rv)); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)) (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) (loc_region_only false (V.frameOf rv))) hh0 hh2; assert (rv_inv #a #rst #rg hh2 frv); // Correctness as_seq_seq_preserved rg (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)) (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) (loc_region_only false (V.frameOf rv))) hh0 hh2; as_seq_seq_slice rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (U32.v i) (U32.v (V.size_of rv)); assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))) (as_seq_seq rg hh2 (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)))); as_seq_seq_eq rg hh2 (V.as_seq hh0 rv) (V.as_seq hh2 frv) (U32.v i) (U32.v (V.size_of rv)) 0 (U32.v (V.size_of frv)); assert (S.equal (as_seq_seq rg hh2 (V.as_seq hh2 frv) 0 (U32.v (V.size_of frv))) (as_seq_seq rg hh2 (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)))); assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))) (as_seq hh2 frv)); frv val free_elems_from: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> idx:uint32_t{idx < V.size_of rv} -> HST.ST unit (requires (fun h0 -> V.live h0 rv /\ rv_elems_inv h0 rv idx (V.size_of rv) /\ rv_elems_reg h0 rv idx (V.size_of rv))) (ensures (fun h0 _ h1 -> modifies (rv_loc_elems h0 rv idx (V.size_of rv)) h0 h1)) let rec free_elems_from #a #rst #rg rv idx = let hh0 = HST.get () in rs_loc_elems_elem_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v idx) (U32.v (V.size_of rv)) (U32.v idx+1) (U32.v (V.size_of rv)) (U32.v idx); rg_free rg (V.index rv idx); let hh1 = HST.get () in rv_elems_inv_preserved rv (idx+1ul) (V.size_of rv) (rv_loc_elem hh0 rv idx) hh0 hh1; if idx + 1ul < V.size_of rv then begin free_elems_from rv (idx + 1ul); rs_loc_elems_rec_inverse rg (V.as_seq hh0 rv) (U32.v idx) (U32.v (V.size_of rv)) end val shrink: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> new_size:uint32_t{new_size <= V.size_of rv} -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv)) (ensures (fun h0 frv h1 -> V.size_of frv = new_size /\ V.frameOf rv = V.frameOf frv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 frv /\ S.equal (as_seq h1 frv) (S.slice (as_seq h0 rv) 0 (U32.v new_size))))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rv: LowStar.RVector.rvector rg -> new_size: LowStar.Vector.uint32_t{new_size <= LowStar.Vector.size_of rv} -> FStar.HyperStack.ST.ST (LowStar.RVector.rvector rg)
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Vector.uint32_t", "Prims.b2t", "FStar.Integers.op_Less_Equals", "FStar.Integers.Unsigned", "FStar.Integers.W32", "LowStar.Vector.size_of", "FStar.Integers.op_Greater_Equals", "Prims.bool", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "LowStar.Regional.__proj__Rgl__item__repr", "FStar.Seq.Base.slice", "LowStar.RVector.as_seq", "LowStar.RVector.as_seq_seq", "LowStar.Vector.as_seq", "LowStar.RVector.as_seq_seq_eq", "LowStar.RVector.as_seq_seq_slice", "LowStar.RVector.as_seq_seq_preserved", "LowStar.Monotonic.Buffer.loc_union", "LowStar.RVector.rs_loc_elems", "LowStar.Monotonic.Buffer.loc_region_only", "LowStar.Vector.frameOf", "LowStar.RVector.rv_inv", "LowStar.RVector.rs_elems_inv_preserved", "LowStar.RVector.rs_loc_elems_parent_disj", "LowStar.RVector.rs_loc_elems_disj", "LowStar.Monotonic.Buffer.modifies", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Vector.vector", "LowStar.Vector.shrink", "LowStar.RVector.rv_loc_elems_included", "LowStar.RVector.free_elems_from", "FStar.UInt.uint_t", "FStar.UInt32.v" ]
[]
false
true
false
false
false
let shrink #a #rst #rg rv new_size =
let size = V.size_of rv in [@@ inline_let ]let sz = U32.v size in [@@ inline_let ]let nsz = U32.v new_size in let hh0 = HST.get () in if new_size >= size then rv else (free_elems_from rv new_size; rv_loc_elems_included hh0 rv new_size size; let hh1 = HST.get () in assert (modifies (rs_loc_elems rg (V.as_seq hh0 rv) nsz sz) hh0 hh1); let frv = V.shrink rv new_size in let hh2 = HST.get () in assert (modifies (loc_region_only false (V.frameOf rv)) hh1 hh2); rs_loc_elems_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 sz 0 nsz nsz sz; rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 nsz; rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 nsz (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) nsz sz) (loc_region_only false (V.frameOf rv))) hh0 hh2; assert (rv_inv #a #rst #rg hh2 frv); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 nsz (loc_union (rs_loc_elems rg (V.as_seq hh0 rv) nsz sz) (loc_region_only false (V.frameOf rv))) hh0 hh2; as_seq_seq_slice rg hh0 (V.as_seq hh0 rv) 0 sz 0 nsz; assert (S.equal (S.slice (as_seq hh0 rv) 0 nsz) (as_seq_seq rg hh2 (V.as_seq hh0 rv) 0 nsz)); as_seq_seq_eq rg hh2 (V.as_seq hh0 rv) (V.as_seq hh2 frv) 0 nsz 0 nsz; assert (S.equal (as_seq_seq rg hh2 (V.as_seq hh2 frv) 0 nsz) (as_seq_seq rg hh2 (V.as_seq hh0 rv) 0 nsz)); assert (S.equal (S.slice (as_seq hh0 rv) 0 nsz) (as_seq hh2 frv)); frv)
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_uint32
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint32:printable FStar.UInt32.t
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_uint32:printable FStar.UInt32.t
instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 134, "start_col": 0, "start_line": 131 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Class.Printable.printable FStar.UInt32.t
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.Mkprintable", "FStar.UInt32.t", "FStar.UInt32.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_uint32:printable FStar.UInt32.t =
{ to_string = FStar.UInt32.to_string }
false
Steel.Effect.fsti
Steel.Effect.bind_ens
val bind_ens: #a: Type -> #b: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #post_g: (a -> post_t b) -> #pr: (a -> prop) -> ens_g: (x: a -> ens_t (pre_g x) b (post_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> post: post_t b -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post) -> ens_t (pre_f `star` frame_f) b post
val bind_ens: #a: Type -> #b: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #post_g: (a -> post_t b) -> #pr: (a -> prop) -> ens_g: (x: a -> ens_t (pre_g x) b (post_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> post: post_t b -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post) -> ens_t (pre_f `star` frame_f) b post
let bind_ens (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_equalities (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y))))
{ "file_name": "lib/steel/Steel.Effect.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 108, "end_line": 113, "start_col": 0, "start_line": 90 }
(* 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.Effect open Steel.Memory module Mem = Steel.Memory module FExt = FStar.FunctionalExtensionality open FStar.Ghost module T = FStar.Tactics include Steel.Effect.Common /// This module defines the main Steel effect, with requires and ensures predicates operating on /// selectors, which will be discharged by SMT #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" (* Defining the Steel effect with selectors *) /// The underlying representation of Steel computations. /// The framed bit indicates whether this computation has already been framed. This corresponds to the |- and |-_F modalities /// in the ICFP21 paper val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2 /// Logical precondition of the return combinator unfold let return_req (p:vprop) : req_t p = fun _ -> True /// Logical postcondition of the return combinator: /// The returned value [r] corresponds to the value passed to the return [x], /// and return leaves selectors of all resources in [p] unchanged unfold let return_ens (a:Type) (x:a) (p:a -> vprop) : ens_t (p x) a p = fun (h0:rmem (p x)) (r:a) (h1:rmem (p r)) -> r == x /\ frame_equalities (p x) h0 (focus_rmem h1 (p x)) /// Monadic return combinator for the Steel effect. It is parametric in the postcondition /// The vprop precondition is annotated with the return_pre predicate to enable special handling, /// as explained in Steel.Effect.Common val return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : repr a true (return_pre (p x)) p (return_req (p x)) (return_ens a x p) /// Logical precondition for the composition (bind) of two Steel computations: /// The postcondition of the first computation must imply the precondition of the second computation, /// and also ensure that any equalities abducted during frame inference inside the predicate [pr] are satisfied unfold let bind_req (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) /// Logical postcondition for the composition (bind) of two Steel computations: /// The precondition of the first computation was satisfied in the initial state, and there /// exists an intermediate state where the two-state postcondition of the first computation was /// satisfied, and which yields the validity of the two-state postcondition of the second computation /// on the final state [m2] with the returned value [y] /// Note that the ensures for the bind below asserts req_f /// This is not necessary, but an explicit assert may help the solver
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Steel.Effect.fsti" }
[ { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> ens_g: (x: a -> Steel.Effect.Common.ens_t (pre_g x) b (post_g x)) -> frame_f: Steel.Effect.Common.vprop -> frame_g: (_: a -> Steel.Effect.Common.vprop) -> post: Steel.Effect.Common.post_t b -> _: Prims.squash (Steel.Effect.Common.can_be_split_forall_dep pr (fun x -> Steel.Effect.Common.star (post_f x) frame_f) (fun x -> Steel.Effect.Common.star (pre_g x) (frame_g x))) -> _: Prims.squash (Steel.Effect.Common.can_be_split_post (fun x y -> Steel.Effect.Common.star (post_g x y) (frame_g x)) post) -> Steel.Effect.Common.ens_t (Steel.Effect.Common.star pre_f frame_f) b post
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Prims.prop", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.can_be_split_forall_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.can_be_split_post", "Steel.Effect.Common.rmem", "Prims.l_and", "Steel.Effect.Common.focus_rmem", "Prims.l_Exists", "Steel.Effect.Common.hmem", "Steel.Effect.Common.frame_equalities", "Steel.Effect.Common.mk_rmem", "Prims.unit", "Steel.Effect.Common.can_be_split_trans" ]
[]
false
false
false
false
false
let bind_ens (#a: Type) (#b: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: (a -> pre_t)) (#post_g: (a -> post_t b)) (#pr: (a -> prop)) (ens_g: (x: a -> ens_t (pre_g x) b (post_g x))) (frame_f: vprop) (frame_g: (a -> vprop)) (post: post_t b) (_: squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x)))) (_: squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post)) : ens_t (pre_f `star` frame_f) b post =
fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x: a) (h1: hmem ((post_f x) `star` frame_f)). pr x /\ (can_be_split_trans ((post_f x) `star` frame_f) ((pre_g x) `star` (frame_g x)) (pre_g x); can_be_split_trans ((post_f x) `star` frame_f) ((pre_g x) `star` (frame_g x)) (frame_g x); can_be_split_trans (post y) ((post_g x y) `star` (frame_g x)) (post_g x y); can_be_split_trans (post y) ((post_g x y) `star` (frame_g x)) (frame_g x); frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) frame_f) /\ frame_equalities (frame_g x) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y))))
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_lemma_Compute_ghash_incremental_register
val va_lemma_Compute_ghash_incremental_register : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_ghash_incremental_register ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))))))))))
val va_lemma_Compute_ghash_incremental_register : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_ghash_incremental_register ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))))))))))
let va_lemma_Compute_ghash_incremental_register va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_ghash_incremental_register va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_ghash_incremental_register ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 109 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 122 column 89 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 244, "start_col": 0, "start_line": 229 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) = (va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0) //-- //-- ReduceMul128_LE val va_code_ReduceMul128_LE : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_ReduceMul128_LE () = (va_Block (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CCons (va_code_ReduceMulRev128 ()) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CNil ()))))) val va_codegen_success_ReduceMul128_LE : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_ReduceMul128_LE () = (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_ReduceMulRev128 ()) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_ReduceMul128_LE (va_mods:va_mods_t) (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (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 104 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMulRev128 a b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 106 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QEmpty (())))))) val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_ReduceMul128_LE va_b0 va_s0 a b = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok] in let va_qc = va_qcode_ReduceMul128_LE va_mods a b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceMul128_LE ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 87 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 102 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_ReduceMul128_LE (a:poly) (b:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) . let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) ==> va_k va_sM (()))) val va_wpProof_ReduceMul128_LE : a:poly -> b:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_ReduceMul128_LE a b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_ReduceMul128_LE a b va_s0 va_k = let (va_sM, va_f0) = va_lemma_ReduceMul128_LE (va_code_ReduceMul128_LE ()) va_s0 a b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_ReduceMul128_LE (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (va_QProc (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) (va_wp_ReduceMul128_LE a b) (va_wpProof_ReduceMul128_LE a b)) //-- //-- Compute_ghash_incremental_register [@ "opaque_to_smt" va_qattr] let va_code_Compute_ghash_incremental_register () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (va_CCons (va_code_ReduceMul128_LE ()) (va_CNil ()))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_ghash_incremental_register () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_ReduceMul128_LE ()) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_ghash_incremental_register (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_ghash_incremental_register ())) = (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 124 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 125 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 127 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMul128_LE (Vale.AES.GF128_s.gf128_of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 1 va_s))) (Vale.AES.GF128_s.gf128_of_quad32 (va_get_xmm 11 va_s))) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 128 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.AES.GHash.ghash_incremental_reveal ()) (va_QEmpty (())))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR12", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.GHash.va_code_Compute_ghash_incremental_register", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.va_get_xmm", "Vale.AES.GHash.ghash_incremental", "Vale.Def.Types_s.reverse_bytes_quad32", "FStar.Seq.Base.create", "Vale.X64.Decls.quad32", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.GHash.va_qcode_Compute_ghash_incremental_register" ]
[]
false
false
false
false
false
let va_lemma_Compute_ghash_incremental_register va_b0 va_s0 =
let va_mods:va_mods_t = [ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1; va_Mod_ok ] in let va_qc = va_qcode_Compute_ghash_incremental_register va_mods in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Compute_ghash_incremental_register ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 109 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 122 column 89 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1; va_Mod_ok ]) va_sM va_s0; (va_sM, va_fM)
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_tuple3
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple3 (#t0 #t1 #t2: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} : printable (tuple3 t0 t1 t2)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple3 (#t0 #t1 #t2: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} : printable (tuple3 t0 t1 t2)
instance printable_tuple3 #t0 #t1 #t2 {| printable t0 |} {| printable t1 |} {| printable t2 |} : printable (tuple3 t0 t1 t2) = { to_string = (fun (v0,v1,v2) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ")" ) }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 175, "start_col": 0, "start_line": 164 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string } instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string } (* Placeholders in case someone build a 128 bit integer printer. instance printable_int128 : printable FStar.Int128.t = { to_string = FStar.Int128.to_string } instance printable_uint128 : printable FStar.UInt128.t = { to_string = FStar.UInt128.to_string } *) (* Up to 7 sized tuples, anything more and why are you using tuples? *) instance printable_tuple2 #a #b {| printable a |} {| printable b |} : printable (a & b) = { to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable t0 |} -> {| _: FStar.Class.Printable.printable t1 |} -> {| _: FStar.Class.Printable.printable t2 |} -> FStar.Class.Printable.printable ((t0 * t1) * t2)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.Native.tuple3", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_tuple3 #t0 #t1 #t2 {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} : printable (tuple3 t0 t1 t2) =
{ to_string = (fun (v0, v1, v2) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ")") }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_tuple2
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple2 (#a #b: _) {| _: printable a |} {| _: printable b |} : printable (a & b)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple2 (#a #b: _) {| _: printable a |} {| _: printable b |} : printable (a & b)
instance printable_tuple2 #a #b {| printable a |} {| printable b |} : printable (a & b) = { to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 162, "start_col": 0, "start_line": 159 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string } instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string } (* Placeholders in case someone build a 128 bit integer printer. instance printable_int128 : printable FStar.Int128.t = { to_string = FStar.Int128.to_string } instance printable_uint128 : printable FStar.UInt128.t = { to_string = FStar.UInt128.to_string } *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable a |} -> {| _: FStar.Class.Printable.printable b |} -> FStar.Class.Printable.printable (a * b)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.Native.tuple2", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_tuple2 #a #b {| _: printable a |} {| _: printable b |} : printable (a & b) =
{ to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") }
false
Steel.Effect.fsti
Steel.Effect.return_ens
val return_ens (a: Type) (x: a) (p: (a -> vprop)) : ens_t (p x) a p
val return_ens (a: Type) (x: a) (p: (a -> vprop)) : ens_t (p x) a p
let return_ens (a:Type) (x:a) (p:a -> vprop) : ens_t (p x) a p = fun (h0:rmem (p x)) (r:a) (h1:rmem (p r)) -> r == x /\ frame_equalities (p x) h0 (focus_rmem h1 (p x))
{ "file_name": "lib/steel/Steel.Effect.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 50, "start_col": 0, "start_line": 48 }
(* 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.Effect open Steel.Memory module Mem = Steel.Memory module FExt = FStar.FunctionalExtensionality open FStar.Ghost module T = FStar.Tactics include Steel.Effect.Common /// This module defines the main Steel effect, with requires and ensures predicates operating on /// selectors, which will be discharged by SMT #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" (* Defining the Steel effect with selectors *) /// The underlying representation of Steel computations. /// The framed bit indicates whether this computation has already been framed. This corresponds to the |- and |-_F modalities /// in the ICFP21 paper val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2 /// Logical precondition of the return combinator unfold let return_req (p:vprop) : req_t p = fun _ -> True /// Logical postcondition of the return combinator: /// The returned value [r] corresponds to the value passed to the return [x], /// and return leaves selectors of all resources in [p] unchanged
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Steel.Effect.fsti" }
[ { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> p: (_: a -> Steel.Effect.Common.vprop) -> Steel.Effect.Common.ens_t (p x) a p
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_and", "Prims.eq2", "Steel.Effect.Common.frame_equalities", "Steel.Effect.Common.focus_rmem", "Steel.Effect.Common.ens_t" ]
[]
false
false
false
false
false
let return_ens (a: Type) (x: a) (p: (a -> vprop)) : ens_t (p x) a p =
fun (h0: rmem (p x)) (r: a) (h1: rmem (p r)) -> r == x /\ frame_equalities (p x) h0 (focus_rmem h1 (p x))
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_tuple5
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple5 (#t0 #t1 #t2 #t3 #t4: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} : printable (tuple5 t0 t1 t2 t3 t4)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple5 (#t0 #t1 #t2 #t3 #t4: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} : printable (tuple5 t0 t1 t2 t3 t4)
instance printable_tuple5 #t0 #t1 #t2 #t3 #t4 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} : printable (tuple5 t0 t1 t2 t3 t4) = { to_string = (fun (v0,v1,v2,v3,v4) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ")" ) }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 205, "start_col": 0, "start_line": 191 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string } instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string } (* Placeholders in case someone build a 128 bit integer printer. instance printable_int128 : printable FStar.Int128.t = { to_string = FStar.Int128.to_string } instance printable_uint128 : printable FStar.UInt128.t = { to_string = FStar.UInt128.to_string } *) (* Up to 7 sized tuples, anything more and why are you using tuples? *) instance printable_tuple2 #a #b {| printable a |} {| printable b |} : printable (a & b) = { to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") } instance printable_tuple3 #t0 #t1 #t2 {| printable t0 |} {| printable t1 |} {| printable t2 |} : printable (tuple3 t0 t1 t2) = { to_string = (fun (v0,v1,v2) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ")" ) } instance printable_tuple4 #t0 #t1 #t2 #t3 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} : printable (tuple4 t0 t1 t2 t3) = { to_string = (fun (v0,v1,v2,v3) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ")" ) }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable t0 |} -> {| _: FStar.Class.Printable.printable t1 |} -> {| _: FStar.Class.Printable.printable t2 |} -> {| _: FStar.Class.Printable.printable t3 |} -> {| _: FStar.Class.Printable.printable t4 |} -> FStar.Class.Printable.printable ((((t0 * t1) * t2) * t3) * t4)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.Native.tuple5", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_tuple5 #t0 #t1 #t2 #t3 #t4 {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} : printable (tuple5 t0 t1 t2 t3 t4) =
{ to_string = (fun (v0, v1, v2, v3, v4) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ")") }
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_lemma_ReduceMul128_LE
val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))))
val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))))
let va_lemma_ReduceMul128_LE va_b0 va_s0 a b = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok] in let va_qc = va_qcode_ReduceMul128_LE va_mods a b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceMul128_LE ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 87 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 102 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 155, "start_col": 0, "start_line": 141 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) = (va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0) //-- //-- ReduceMul128_LE val va_code_ReduceMul128_LE : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_ReduceMul128_LE () = (va_Block (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CCons (va_code_ReduceMulRev128 ()) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CNil ()))))) val va_codegen_success_ReduceMul128_LE : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_ReduceMul128_LE () = (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_ReduceMulRev128 ()) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_ReduceMul128_LE (va_mods:va_mods_t) (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (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 104 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMulRev128 a b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 106 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QEmpty (())))))) val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> a: Vale.Math.Poly2_s.poly -> b: Vale.Math.Poly2_s.poly -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.Math.Poly2_s.poly", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR12", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.GHash.va_code_ReduceMul128_LE", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.va_get_xmm", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.AES.GF128_s.gf128_to_quad32", "Vale.AES.GF128_s.gf128_mul", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.GHash.va_qcode_ReduceMul128_LE" ]
[]
false
false
false
false
false
let va_lemma_ReduceMul128_LE va_b0 va_s0 a b =
let va_mods:va_mods_t = [ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok ] in let va_qc = va_qcode_ReduceMul128_LE va_mods a b in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_ReduceMul128_LE ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 87 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 102 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok ]) va_sM va_s0; (va_sM, va_fM)
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_tuple4
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple4 (#t0 #t1 #t2 #t3: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} : printable (tuple4 t0 t1 t2 t3)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple4 (#t0 #t1 #t2 #t3: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} : printable (tuple4 t0 t1 t2 t3)
instance printable_tuple4 #t0 #t1 #t2 #t3 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} : printable (tuple4 t0 t1 t2 t3) = { to_string = (fun (v0,v1,v2,v3) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ")" ) }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 189, "start_col": 0, "start_line": 177 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string } instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string } (* Placeholders in case someone build a 128 bit integer printer. instance printable_int128 : printable FStar.Int128.t = { to_string = FStar.Int128.to_string } instance printable_uint128 : printable FStar.UInt128.t = { to_string = FStar.UInt128.to_string } *) (* Up to 7 sized tuples, anything more and why are you using tuples? *) instance printable_tuple2 #a #b {| printable a |} {| printable b |} : printable (a & b) = { to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") } instance printable_tuple3 #t0 #t1 #t2 {| printable t0 |} {| printable t1 |} {| printable t2 |} : printable (tuple3 t0 t1 t2) = { to_string = (fun (v0,v1,v2) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ")" ) }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable t0 |} -> {| _: FStar.Class.Printable.printable t1 |} -> {| _: FStar.Class.Printable.printable t2 |} -> {| _: FStar.Class.Printable.printable t3 |} -> FStar.Class.Printable.printable (((t0 * t1) * t2) * t3)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.Native.tuple4", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_tuple4 #t0 #t1 #t2 #t3 {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} : printable (tuple4 t0 t1 t2 t3) =
{ to_string = (fun (v0, v1, v2, v3) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ")") }
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_qcode_Compute_ghash_incremental_register
val va_qcode_Compute_ghash_incremental_register (va_mods: va_mods_t) : (va_quickCode unit (va_code_Compute_ghash_incremental_register ()))
val va_qcode_Compute_ghash_incremental_register (va_mods: va_mods_t) : (va_quickCode unit (va_code_Compute_ghash_incremental_register ()))
let va_qcode_Compute_ghash_incremental_register (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_ghash_incremental_register ())) = (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 124 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 125 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 127 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMul128_LE (Vale.AES.GF128_s.gf128_of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 1 va_s))) (Vale.AES.GF128_s.gf128_of_quad32 (va_get_xmm 11 va_s))) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 128 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.AES.GHash.ghash_incremental_reveal ()) (va_QEmpty (())))))))
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 86, "end_line": 226, "start_col": 0, "start_line": 213 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) = (va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0) //-- //-- ReduceMul128_LE val va_code_ReduceMul128_LE : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_ReduceMul128_LE () = (va_Block (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CCons (va_code_ReduceMulRev128 ()) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CNil ()))))) val va_codegen_success_ReduceMul128_LE : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_ReduceMul128_LE () = (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_ReduceMulRev128 ()) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_ReduceMul128_LE (va_mods:va_mods_t) (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (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 104 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMulRev128 a b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 106 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QEmpty (())))))) val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_ReduceMul128_LE va_b0 va_s0 a b = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok] in let va_qc = va_qcode_ReduceMul128_LE va_mods a b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceMul128_LE ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 87 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 102 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_ReduceMul128_LE (a:poly) (b:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) . let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) ==> va_k va_sM (()))) val va_wpProof_ReduceMul128_LE : a:poly -> b:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_ReduceMul128_LE a b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_ReduceMul128_LE a b va_s0 va_k = let (va_sM, va_f0) = va_lemma_ReduceMul128_LE (va_code_ReduceMul128_LE ()) va_s0 a b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_ReduceMul128_LE (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (va_QProc (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) (va_wp_ReduceMul128_LE a b) (va_wpProof_ReduceMul128_LE a b)) //-- //-- Compute_ghash_incremental_register [@ "opaque_to_smt" va_qattr] let va_code_Compute_ghash_incremental_register () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (va_CCons (va_code_ReduceMul128_LE ()) (va_CNil ()))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_ghash_incremental_register () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_ReduceMul128_LE ()) (va_ttrue ()))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_mods: Vale.X64.QuickCode.va_mods_t -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.GHash.va_code_Compute_ghash_incremental_register ())
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsVector.va_code_Pxor", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.InsVector.va_code_Mov128", "Vale.AES.X64.GHash.va_code_ReduceMul128_LE", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsVector.va_quick_Pxor", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.InsVector.va_quick_Mov128", "Vale.AES.X64.GHash.va_quick_ReduceMul128_LE", "Vale.AES.GF128_s.gf128_of_quad32", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.X64.Decls.va_get_xmm", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.AES.GHash.ghash_incremental", "Vale.AES.GHash.ghash_incremental_def", "Vale.AES.GHash.ghash_incremental_reveal", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.GHash.va_code_Compute_ghash_incremental_register" ]
[]
false
false
false
false
false
let va_qcode_Compute_ghash_incremental_register (va_mods: va_mods_t) : (va_quickCode unit (va_code_Compute_ghash_incremental_register ())) =
(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 124 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 125 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (fun (va_s: va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 127 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMul128_LE (Vale.AES.GF128_s.gf128_of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 1 va_s))) (Vale.AES.GF128_s.gf128_of_quad32 (va_get_xmm 11 va_s))) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 128 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_: unit) -> Vale.AES.GHash.ghash_incremental_reveal ()) (va_QEmpty (())))))))
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_tuple6
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple6 (#t0 #t1 #t2 #t3 #t4 #t5: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} {| _: printable t5 |} : printable (tuple6 t0 t1 t2 t3 t4 t5)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple6 (#t0 #t1 #t2 #t3 #t4 #t5: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} {| _: printable t5 |} : printable (tuple6 t0 t1 t2 t3 t4 t5)
instance printable_tuple6 #t0 #t1 #t2 #t3 #t4 #t5 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} {| printable t5 |} : printable (tuple6 t0 t1 t2 t3 t4 t5) = { to_string = (fun (v0,v1,v2,v3,v4,v5) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ", " ^ to_string v5 ^ ")" ) }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 222, "start_col": 0, "start_line": 207 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string } instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string } (* Placeholders in case someone build a 128 bit integer printer. instance printable_int128 : printable FStar.Int128.t = { to_string = FStar.Int128.to_string } instance printable_uint128 : printable FStar.UInt128.t = { to_string = FStar.UInt128.to_string } *) (* Up to 7 sized tuples, anything more and why are you using tuples? *) instance printable_tuple2 #a #b {| printable a |} {| printable b |} : printable (a & b) = { to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") } instance printable_tuple3 #t0 #t1 #t2 {| printable t0 |} {| printable t1 |} {| printable t2 |} : printable (tuple3 t0 t1 t2) = { to_string = (fun (v0,v1,v2) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ")" ) } instance printable_tuple4 #t0 #t1 #t2 #t3 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} : printable (tuple4 t0 t1 t2 t3) = { to_string = (fun (v0,v1,v2,v3) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ")" ) } instance printable_tuple5 #t0 #t1 #t2 #t3 #t4 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} : printable (tuple5 t0 t1 t2 t3 t4) = { to_string = (fun (v0,v1,v2,v3,v4) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ")" ) }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable t0 |} -> {| _: FStar.Class.Printable.printable t1 |} -> {| _: FStar.Class.Printable.printable t2 |} -> {| _: FStar.Class.Printable.printable t3 |} -> {| _: FStar.Class.Printable.printable t4 |} -> {| _: FStar.Class.Printable.printable t5 |} -> FStar.Class.Printable.printable (((((t0 * t1) * t2) * t3) * t4) * t5)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.Native.tuple6", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_tuple6 #t0 #t1 #t2 #t3 #t4 #t5 {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} {| _: printable t5 |} : printable (tuple6 t0 t1 t2 t3 t4 t5) =
{ to_string = (fun (v0, v1, v2, v3, v4, v5) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ", " ^ to_string v5 ^ ")") }
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_seq
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_seq (#b: Type) (x: printable b) : printable (Seq.seq b)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_seq (#b: Type) (x: printable b) : printable (Seq.seq b)
instance printable_seq (#b:Type) (x:printable b) : printable (Seq.seq b) = { to_string = (fun s -> let strings_of_b = map_seq to_string s in "<" ^ FStar.String.concat "; " (Seq.seq_to_list strings_of_b) ^ ">") }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 266, "start_col": 0, "start_line": 257 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string } instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string } (* Placeholders in case someone build a 128 bit integer printer. instance printable_int128 : printable FStar.Int128.t = { to_string = FStar.Int128.to_string } instance printable_uint128 : printable FStar.UInt128.t = { to_string = FStar.UInt128.to_string } *) (* Up to 7 sized tuples, anything more and why are you using tuples? *) instance printable_tuple2 #a #b {| printable a |} {| printable b |} : printable (a & b) = { to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") } instance printable_tuple3 #t0 #t1 #t2 {| printable t0 |} {| printable t1 |} {| printable t2 |} : printable (tuple3 t0 t1 t2) = { to_string = (fun (v0,v1,v2) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ")" ) } instance printable_tuple4 #t0 #t1 #t2 #t3 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} : printable (tuple4 t0 t1 t2 t3) = { to_string = (fun (v0,v1,v2,v3) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ")" ) } instance printable_tuple5 #t0 #t1 #t2 #t3 #t4 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} : printable (tuple5 t0 t1 t2 t3 t4) = { to_string = (fun (v0,v1,v2,v3,v4) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ")" ) } instance printable_tuple6 #t0 #t1 #t2 #t3 #t4 #t5 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} {| printable t5 |} : printable (tuple6 t0 t1 t2 t3 t4 t5) = { to_string = (fun (v0,v1,v2,v3,v4,v5) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ", " ^ to_string v5 ^ ")" ) } instance printable_tuple7 #t0 #t1 #t2 #t3 #t4 #t5 #t6 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} {| printable t5 |} {| printable t6 |} : printable (tuple7 t0 t1 t2 t3 t4 t5 t6) = { to_string = (fun (v0,v1,v2,v3,v4,v5,v6) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ", " ^ to_string v5 ^ ", " ^ to_string v6 ^ ")" ) } (* Sequences, with a <...> syntax. *) (* instance printable_seq (#a:Type) (x:printable a) : printable (Seq.seq a) = { to_string = (fun l -> "<" ^ FStar.String.concat "; " (List.Tot.map to_string (Seq.seq_to_list l)) ^ ">") } *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Class.Printable.printable b -> FStar.Class.Printable.printable (FStar.Seq.Base.seq b)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Seq.Base.seq", "Prims.op_Hat", "FStar.String.concat", "FStar.Seq.Base.seq_to_list", "Prims.string", "FStar.Seq.Properties.map_seq", "FStar.Class.Printable.to_string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_seq (#b: Type) (x: printable b) : printable (Seq.seq b) =
{ to_string = (fun s -> let strings_of_b = map_seq to_string s in "<" ^ FStar.String.concat "; " (Seq.seq_to_list strings_of_b) ^ ">") }
false
Steel.Effect.fsti
Steel.Effect.bind_req
val bind_req: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #pr: (a -> prop) -> req_g: (x: a -> req_t (pre_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> req_t (pre_f `star` frame_f)
val bind_req: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: (a -> pre_t) -> #pr: (a -> prop) -> req_g: (x: a -> req_t (pre_g x)) -> frame_f: vprop -> frame_g: (a -> vprop) -> squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x))) -> req_t (pre_f `star` frame_f)
let bind_req (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x))))
{ "file_name": "lib/steel/Steel.Effect.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 79, "end_line": 78, "start_col": 0, "start_line": 62 }
(* 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.Effect open Steel.Memory module Mem = Steel.Memory module FExt = FStar.FunctionalExtensionality open FStar.Ghost module T = FStar.Tactics include Steel.Effect.Common /// This module defines the main Steel effect, with requires and ensures predicates operating on /// selectors, which will be discharged by SMT #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" (* Defining the Steel effect with selectors *) /// The underlying representation of Steel computations. /// The framed bit indicates whether this computation has already been framed. This corresponds to the |- and |-_F modalities /// in the ICFP21 paper val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2 /// Logical precondition of the return combinator unfold let return_req (p:vprop) : req_t p = fun _ -> True /// Logical postcondition of the return combinator: /// The returned value [r] corresponds to the value passed to the return [x], /// and return leaves selectors of all resources in [p] unchanged unfold let return_ens (a:Type) (x:a) (p:a -> vprop) : ens_t (p x) a p = fun (h0:rmem (p x)) (r:a) (h1:rmem (p r)) -> r == x /\ frame_equalities (p x) h0 (focus_rmem h1 (p x)) /// Monadic return combinator for the Steel effect. It is parametric in the postcondition /// The vprop precondition is annotated with the return_pre predicate to enable special handling, /// as explained in Steel.Effect.Common val return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : repr a true (return_pre (p x)) p (return_req (p x)) (return_ens a x p) /// Logical precondition for the composition (bind) of two Steel computations: /// The postcondition of the first computation must imply the precondition of the second computation, /// and also ensure that any equalities abducted during frame inference inside the predicate [pr] are satisfied
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Steel.Effect.fsti" }
[ { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> req_g: (x: a -> Steel.Effect.Common.req_t (pre_g x)) -> frame_f: Steel.Effect.Common.vprop -> frame_g: (_: a -> Steel.Effect.Common.vprop) -> _: Prims.squash (Steel.Effect.Common.can_be_split_forall_dep pr (fun x -> Steel.Effect.Common.star (post_f x) frame_f) (fun x -> Steel.Effect.Common.star (pre_g x) (frame_g x))) -> Steel.Effect.Common.req_t (Steel.Effect.Common.star pre_f frame_f)
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Prims.prop", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.can_be_split_forall_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.rmem", "Prims.l_and", "Steel.Effect.Common.focus_rmem", "Prims.l_Forall", "Steel.Effect.Common.hmem", "Prims.l_imp", "Steel.Effect.Common.mk_rmem", "Steel.Effect.Common.frame_equalities", "Prims.unit", "Steel.Effect.Common.can_be_split_trans" ]
[]
false
false
false
false
false
let bind_req (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: (a -> pre_t)) (#pr: (a -> prop)) (req_g: (x: a -> req_t (pre_g x))) (frame_f: vprop) (frame_g: (a -> vprop)) (_: squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x)))) : req_t (pre_f `star` frame_f) =
fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x: a) (h1: hmem ((post_f x) `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (post_f x)) /\ frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans ((post_f x) `star` frame_f) ((pre_g x) `star` (frame_g x)) (pre_g x); (req_g x) (focus_rmem (mk_rmem ((post_f x) `star` frame_f) h1) (pre_g x))))
false
LowStar.RVector.fst
LowStar.RVector.as_seq_seq_slice
val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k)))
val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k)))
let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1))
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 597, "start_col": 0, "start_line": 590 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> h: FStar.Monotonic.HyperStack.mem -> rs: FStar.Seq.Base.seq a -> i: FStar.Integers.nat -> j: FStar.Integers.nat {i <= j /\ j <= FStar.Seq.Base.length rs /\ LowStar.RVector.rs_elems_inv rg h rs i j} -> k: FStar.Integers.nat -> l: FStar.Integers.nat{k <= l && l <= j - i} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (FStar.Seq.Base.slice (LowStar.RVector.as_seq_seq rg h rs i j) k l) (LowStar.RVector.as_seq_seq rg h (FStar.Seq.Base.slice rs (i + k) (i + l)) 0 (l - k)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowStar.Regional.regional", "FStar.Monotonic.HyperStack.mem", "FStar.Seq.Base.seq", "FStar.Integers.nat", "Prims.l_and", "Prims.b2t", "FStar.Integers.op_Less_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.length", "LowStar.RVector.rs_elems_inv", "Prims.op_AmpAmp", "FStar.Integers.op_Subtraction", "Prims.op_Equality", "Prims.bool", "LowStar.RVector.as_seq_seq_eq", "FStar.Seq.Base.slice", "FStar.Integers.op_Plus", "Prims.unit", "LowStar.RVector.as_seq_seq_index", "LowStar.RVector.as_seq_seq_slice" ]
[ "recursion" ]
false
false
true
false
false
let rec as_seq_seq_slice #a #rst rg h rs i j k l =
if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1))
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_option
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_option (#a: _) {| _: printable a |} : printable (option a)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_option (#a: _) {| _: printable a |} : printable (option a)
instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 72, "start_col": 0, "start_line": 69 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable a |} -> FStar.Class.Printable.printable (FStar.Pervasives.Native.option a)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.Native.option", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_option #a {| _: printable a |} : printable (option a) =
{ to_string = (function | None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") }
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_wpProof_Compute_Y0
val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 92, "start_col": 0, "start_line": 85 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.GHash.va_lemma_Compute_Y0", "Vale.AES.X64.GHash.va_code_Compute_Y0" ]
[]
false
false
false
false
false
let va_wpProof_Compute_Y0 va_s0 va_k =
let va_sM, va_f0 = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))) ); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Steel.Effect.fsti
Steel.Effect.if_then_else_req
val if_then_else_req (#pre_f #pre_g: pre_t) (#frame_f #frame_g: vprop) (#pr: prop) (s_pre: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (req_then: req_t pre_f) (req_else: req_t pre_g) (p: Type0) : req_t (pre_f `star` frame_f)
val if_then_else_req (#pre_f #pre_g: pre_t) (#frame_f #frame_g: vprop) (#pr: prop) (s_pre: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (req_then: req_t pre_f) (req_else: req_t pre_g) (p: Type0) : req_t (pre_f `star` frame_f)
let if_then_else_req (#pre_f:pre_t) (#pre_g:pre_t) (#frame_f #frame_g:vprop) (#pr: prop) (s_pre: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (req_then:req_t pre_f) (req_else:req_t pre_g) (p:Type0) : req_t (pre_f `star` frame_f) = fun h -> pr /\ ( can_be_split_trans (pre_f `star` frame_f) (pre_g `star` frame_g) pre_g; (p ==> req_then (focus_rmem h pre_f)) /\ ((~ p) ==> req_else (focus_rmem h pre_g)))
{ "file_name": "lib/steel/Steel.Effect.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 46, "end_line": 210, "start_col": 0, "start_line": 201 }
(* 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.Effect open Steel.Memory module Mem = Steel.Memory module FExt = FStar.FunctionalExtensionality open FStar.Ghost module T = FStar.Tactics include Steel.Effect.Common /// This module defines the main Steel effect, with requires and ensures predicates operating on /// selectors, which will be discharged by SMT #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" (* Defining the Steel effect with selectors *) /// The underlying representation of Steel computations. /// The framed bit indicates whether this computation has already been framed. This corresponds to the |- and |-_F modalities /// in the ICFP21 paper val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2 /// Logical precondition of the return combinator unfold let return_req (p:vprop) : req_t p = fun _ -> True /// Logical postcondition of the return combinator: /// The returned value [r] corresponds to the value passed to the return [x], /// and return leaves selectors of all resources in [p] unchanged unfold let return_ens (a:Type) (x:a) (p:a -> vprop) : ens_t (p x) a p = fun (h0:rmem (p x)) (r:a) (h1:rmem (p r)) -> r == x /\ frame_equalities (p x) h0 (focus_rmem h1 (p x)) /// Monadic return combinator for the Steel effect. It is parametric in the postcondition /// The vprop precondition is annotated with the return_pre predicate to enable special handling, /// as explained in Steel.Effect.Common val return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : repr a true (return_pre (p x)) p (return_req (p x)) (return_ens a x p) /// Logical precondition for the composition (bind) of two Steel computations: /// The postcondition of the first computation must imply the precondition of the second computation, /// and also ensure that any equalities abducted during frame inference inside the predicate [pr] are satisfied unfold let bind_req (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) /// Logical postcondition for the composition (bind) of two Steel computations: /// The precondition of the first computation was satisfied in the initial state, and there /// exists an intermediate state where the two-state postcondition of the first computation was /// satisfied, and which yields the validity of the two-state postcondition of the second computation /// on the final state [m2] with the returned value [y] /// Note that the ensures for the bind below asserts req_f /// This is not necessary, but an explicit assert may help the solver unfold let bind_ens (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_equalities (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) /// Steel effect combinator to compose two Steel computations /// Separation logic VCs are squashed goals passed as implicits, annotated with the framing_implicit /// attribute. This indicates that they will be discharged by the tactic in Steel.Effect.Common /// Requires/ensures logical VCs are defined using weakest preconditions combinators defined above, /// and discharged by SMT. val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(x:a -> req_t (pre_g x))) (#[@@@ framing_implicit] ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req req_f ens_f req_g frame_f frame_g p1) (bind_ens req_f ens_f ens_g frame_f frame_g post p1 p2) /// Logical precondition for subtyping relation for Steel computation. unfold let subcomp_pre (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre // The call to with_tactic allows us to reduce VCs in a controlled way, once all // uvars have been resolved. // To ensure an SMT-friendly encoding of the VC, it needs to be encapsulated in a squash call = T.rewrite_with_tactic vc_norm (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) /// Subtyping combinator for Steel computations. /// Computation [f] is given type `repr a framed_g pre_g post_g req_g ens_g`. /// As for bind, separation logic goals are encoded as squashed implicits which will be discharged /// by tactic, while logical requires/ensures operating on selectors are discharged by SMT val subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) /// Logical precondition for the if_then_else combinator
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Steel.Effect.fsti" }
[ { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s_pre: Prims.squash (Steel.Effect.Common.can_be_split_dep pr (Steel.Effect.Common.star pre_f frame_f) (Steel.Effect.Common.star pre_g frame_g)) -> req_then: Steel.Effect.Common.req_t pre_f -> req_else: Steel.Effect.Common.req_t pre_g -> p: Type0 -> Steel.Effect.Common.req_t (Steel.Effect.Common.star pre_f frame_f)
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.vprop", "Prims.prop", "Prims.squash", "Steel.Effect.Common.can_be_split_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.req_t", "Steel.Effect.Common.rmem", "Prims.l_and", "Prims.l_imp", "Steel.Effect.Common.focus_rmem", "Prims.l_not", "Prims.unit", "Steel.Effect.Common.can_be_split_trans" ]
[]
false
false
false
false
false
let if_then_else_req (#pre_f #pre_g: pre_t) (#frame_f #frame_g: vprop) (#pr: prop) (s_pre: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (req_then: req_t pre_f) (req_else: req_t pre_g) (p: Type0) : req_t (pre_f `star` frame_f) =
fun h -> pr /\ (can_be_split_trans (pre_f `star` frame_f) (pre_g `star` frame_g) pre_g; (p ==> req_then (focus_rmem h pre_f)) /\ ((~p) ==> req_else (focus_rmem h pre_g)))
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_tuple7
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple7 (#t0 #t1 #t2 #t3 #t4 #t5 #t6: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} {| _: printable t5 |} {| _: printable t6 |} : printable (tuple7 t0 t1 t2 t3 t4 t5 t6)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_tuple7 (#t0 #t1 #t2 #t3 #t4 #t5 #t6: _) {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} {| _: printable t5 |} {| _: printable t6 |} : printable (tuple7 t0 t1 t2 t3 t4 t5 t6)
instance printable_tuple7 #t0 #t1 #t2 #t3 #t4 #t5 #t6 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} {| printable t5 |} {| printable t6 |} : printable (tuple7 t0 t1 t2 t3 t4 t5 t6) = { to_string = (fun (v0,v1,v2,v3,v4,v5,v6) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ", " ^ to_string v5 ^ ", " ^ to_string v6 ^ ")" ) }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 241, "start_col": 0, "start_line": 225 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") } instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") } (* Then the base types. *) instance printable_char : printable FStar.Char.char = { to_string = string_of_char } (* Floats are not yet well implemented, so these are placeholders.*) (* instance printable_float : printable FStar.Float.float = { to_string = FStar.Float.to_string } instance printable_double : printable FStar.Float.double = { to_string = FStar.Float.to_string } *) instance printable_byte : printable FStar.UInt8.byte = { to_string = FStar.UInt8.to_string } instance printable_int8 : printable FStar.Int8.t = { to_string = FStar.Int8.to_string } instance printable_uint8 : printable FStar.UInt8.t = { to_string = FStar.UInt8.to_string } instance printable_int16 : printable FStar.Int16.t = { to_string = FStar.Int16.to_string } instance printable_uint16 : printable FStar.UInt16.t = { to_string = FStar.UInt16.to_string } instance printable_int32 : printable FStar.Int32.t = { to_string = FStar.Int32.to_string } instance printable_uint32 : printable FStar.UInt32.t = { to_string = FStar.UInt32.to_string } instance printable_int64 : printable FStar.Int64.t = { to_string = FStar.Int64.to_string } instance printable_uint64 : printable FStar.UInt64.t = { to_string = FStar.UInt64.to_string } (* Placeholders in case someone build a 128 bit integer printer. instance printable_int128 : printable FStar.Int128.t = { to_string = FStar.Int128.to_string } instance printable_uint128 : printable FStar.UInt128.t = { to_string = FStar.UInt128.to_string } *) (* Up to 7 sized tuples, anything more and why are you using tuples? *) instance printable_tuple2 #a #b {| printable a |} {| printable b |} : printable (a & b) = { to_string = (fun (x, y) -> "(" ^ to_string x ^ ", " ^ to_string y ^ ")") } instance printable_tuple3 #t0 #t1 #t2 {| printable t0 |} {| printable t1 |} {| printable t2 |} : printable (tuple3 t0 t1 t2) = { to_string = (fun (v0,v1,v2) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ")" ) } instance printable_tuple4 #t0 #t1 #t2 #t3 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} : printable (tuple4 t0 t1 t2 t3) = { to_string = (fun (v0,v1,v2,v3) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ")" ) } instance printable_tuple5 #t0 #t1 #t2 #t3 #t4 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} : printable (tuple5 t0 t1 t2 t3 t4) = { to_string = (fun (v0,v1,v2,v3,v4) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ")" ) } instance printable_tuple6 #t0 #t1 #t2 #t3 #t4 #t5 {| printable t0 |} {| printable t1 |} {| printable t2 |} {| printable t3 |} {| printable t4 |} {| printable t5 |} : printable (tuple6 t0 t1 t2 t3 t4 t5) = { to_string = (fun (v0,v1,v2,v3,v4,v5) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ", " ^ to_string v5 ^ ")" ) }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable t0 |} -> {| _: FStar.Class.Printable.printable t1 |} -> {| _: FStar.Class.Printable.printable t2 |} -> {| _: FStar.Class.Printable.printable t3 |} -> {| _: FStar.Class.Printable.printable t4 |} -> {| _: FStar.Class.Printable.printable t5 |} -> {| _: FStar.Class.Printable.printable t6 |} -> FStar.Class.Printable.printable ((((((t0 * t1) * t2) * t3) * t4) * t5) * t6)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.Native.tuple7", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_tuple7 #t0 #t1 #t2 #t3 #t4 #t5 #t6 {| _: printable t0 |} {| _: printable t1 |} {| _: printable t2 |} {| _: printable t3 |} {| _: printable t4 |} {| _: printable t5 |} {| _: printable t6 |} : printable (tuple7 t0 t1 t2 t3 t4 t5 t6) =
{ to_string = (fun (v0, v1, v2, v3, v4, v5, v6) -> "(" ^ to_string v0 ^ ", " ^ to_string v1 ^ ", " ^ to_string v2 ^ ", " ^ to_string v3 ^ ", " ^ to_string v4 ^ ", " ^ to_string v5 ^ ", " ^ to_string v6 ^ ")") }
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_wpProof_ReduceMul128_LE
val va_wpProof_ReduceMul128_LE : a:poly -> b:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_ReduceMul128_LE a b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_ReduceMul128_LE : a:poly -> b:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_ReduceMul128_LE a b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_ReduceMul128_LE a b va_s0 va_k = let (va_sM, va_f0) = va_lemma_ReduceMul128_LE (va_code_ReduceMul128_LE ()) va_s0 a b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 191, "start_col": 0, "start_line": 182 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) = (va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0) //-- //-- ReduceMul128_LE val va_code_ReduceMul128_LE : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_ReduceMul128_LE () = (va_Block (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CCons (va_code_ReduceMulRev128 ()) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CNil ()))))) val va_codegen_success_ReduceMul128_LE : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_ReduceMul128_LE () = (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_ReduceMulRev128 ()) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_ReduceMul128_LE (va_mods:va_mods_t) (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (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 104 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMulRev128 a b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 106 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QEmpty (())))))) val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_ReduceMul128_LE va_b0 va_s0 a b = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok] in let va_qc = va_qcode_ReduceMul128_LE va_mods a b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceMul128_LE ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 87 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 102 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_ReduceMul128_LE (a:poly) (b:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) . let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) ==> va_k va_sM (()))) val va_wpProof_ReduceMul128_LE : a:poly -> b:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_ReduceMul128_LE a b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Math.Poly2_s.poly -> b: Vale.Math.Poly2_s.poly -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.Math.Poly2_s.poly", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR12", "Vale.X64.QuickCode.va_Mod_flags", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.GHash.va_lemma_ReduceMul128_LE", "Vale.AES.X64.GHash.va_code_ReduceMul128_LE" ]
[]
false
false
false
false
false
let va_wpProof_ReduceMul128_LE a b va_s0 va_k =
let va_sM, va_f0 = va_lemma_ReduceMul128_LE (va_code_ReduceMul128_LE ()) va_s0 a b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags ]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
FStar.Class.Printable.fst
FStar.Class.Printable.printable_either
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_either (#a #b: _) {| _: printable a |} {| _: printable b |} : printable (either a b)
[@@ FStar.Tactics.Typeclasses.tcinstance] val printable_either (#a #b: _) {| _: printable a |} {| _: printable b |} : printable (either a b)
instance printable_either #a #b {| printable a |} {| printable b |} : printable (either a b) = { to_string = (function Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") }
{ "file_name": "ulib/FStar.Class.Printable.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 79, "start_col": 0, "start_line": 74 }
(* 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. Authors: Brian G. Milnes *) module FStar.Class.Printable open FStar.String open FStar.Seq.Properties class printable (a:Type) = { to_string : a -> string } (* First the prim types. *) instance printable_unit : printable unit = { to_string = (fun _ -> "()") } instance printable_bool : printable bool = { to_string = Prims.string_of_bool } instance printable_nat : printable nat = { to_string = Prims.string_of_int } instance printable_int : printable int = { to_string = Prims.string_of_int } (* An instance for refinements, they can be printed as long as the base type is printable. This allows to print [nat], for instance. *) instance printable_ref #a #p (d : printable a) : printable (x:a{p x}) = { to_string = d.to_string } instance printable_list (#a:Type) (x:printable a) : printable (list a) = { to_string = (fun l -> "[" ^ FStar.String.concat "; " (List.Tot.map to_string l) ^ "]") } instance printable_string : printable string = { to_string = fun x -> "\"" ^ x ^ "\"" } instance printable_option #a {| printable a |} : printable (option a) = { to_string = (function None -> "None" | Some x -> "(Some " ^ to_string x ^ ")") }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Printable.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
{| _: FStar.Class.Printable.printable a |} -> {| _: FStar.Class.Printable.printable b |} -> FStar.Class.Printable.printable (FStar.Pervasives.either a b)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Printable.printable", "FStar.Class.Printable.Mkprintable", "FStar.Pervasives.either", "Prims.op_Hat", "FStar.Class.Printable.to_string", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let printable_either #a #b {| _: printable a |} {| _: printable b |} : printable (either a b) =
{ to_string = (function | Inl x -> "(Inl " ^ to_string x ^ ")" | Inr x -> "(Inr " ^ to_string x ^ ")") }
false
Steel.Effect.fsti
Steel.Effect.subcomp_pre
val subcomp_pre: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: pre_t -> #post_g: post_t a -> req_g: req_t pre_g -> ens_g: ens_t pre_g a post_g -> #frame: vprop -> #pr: prop -> squash (can_be_split_dep pr pre_g (pre_f `star` frame)) -> squash (equiv_forall post_g (fun x -> (post_f x) `star` frame)) -> pure_pre
val subcomp_pre: #a: Type -> #pre_f: pre_t -> #post_f: post_t a -> req_f: req_t pre_f -> ens_f: ens_t pre_f a post_f -> #pre_g: pre_t -> #post_g: post_t a -> req_g: req_t pre_g -> ens_g: ens_t pre_g a post_g -> #frame: vprop -> #pr: prop -> squash (can_be_split_dep pr pre_g (pre_f `star` frame)) -> squash (equiv_forall post_g (fun x -> (post_f x) `star` frame)) -> pure_pre
let subcomp_pre (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre // The call to with_tactic allows us to reduce VCs in a controlled way, once all // uvars have been resolved. // To ensure an SMT-friendly encoding of the VC, it needs to be encapsulated in a squash call = T.rewrite_with_tactic vc_norm (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) ))
{ "file_name": "lib/steel/Steel.Effect.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 2, "end_line": 176, "start_col": 0, "start_line": 146 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Effect open Steel.Memory module Mem = Steel.Memory module FExt = FStar.FunctionalExtensionality open FStar.Ghost module T = FStar.Tactics include Steel.Effect.Common /// This module defines the main Steel effect, with requires and ensures predicates operating on /// selectors, which will be discharged by SMT #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" (* Defining the Steel effect with selectors *) /// The underlying representation of Steel computations. /// The framed bit indicates whether this computation has already been framed. This corresponds to the |- and |-_F modalities /// in the ICFP21 paper val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2 /// Logical precondition of the return combinator unfold let return_req (p:vprop) : req_t p = fun _ -> True /// Logical postcondition of the return combinator: /// The returned value [r] corresponds to the value passed to the return [x], /// and return leaves selectors of all resources in [p] unchanged unfold let return_ens (a:Type) (x:a) (p:a -> vprop) : ens_t (p x) a p = fun (h0:rmem (p x)) (r:a) (h1:rmem (p r)) -> r == x /\ frame_equalities (p x) h0 (focus_rmem h1 (p x)) /// Monadic return combinator for the Steel effect. It is parametric in the postcondition /// The vprop precondition is annotated with the return_pre predicate to enable special handling, /// as explained in Steel.Effect.Common val return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : repr a true (return_pre (p x)) p (return_req (p x)) (return_ens a x p) /// Logical precondition for the composition (bind) of two Steel computations: /// The postcondition of the first computation must imply the precondition of the second computation, /// and also ensure that any equalities abducted during frame inference inside the predicate [pr] are satisfied unfold let bind_req (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) /// Logical postcondition for the composition (bind) of two Steel computations: /// The precondition of the first computation was satisfied in the initial state, and there /// exists an intermediate state where the two-state postcondition of the first computation was /// satisfied, and which yields the validity of the two-state postcondition of the second computation /// on the final state [m2] with the returned value [y] /// Note that the ensures for the bind below asserts req_f /// This is not necessary, but an explicit assert may help the solver unfold let bind_ens (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_equalities (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) /// Steel effect combinator to compose two Steel computations /// Separation logic VCs are squashed goals passed as implicits, annotated with the framing_implicit /// attribute. This indicates that they will be discharged by the tactic in Steel.Effect.Common /// Requires/ensures logical VCs are defined using weakest preconditions combinators defined above, /// and discharged by SMT. val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(x:a -> req_t (pre_g x))) (#[@@@ framing_implicit] ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req req_f ens_f req_g frame_f frame_g p1) (bind_ens req_f ens_f ens_g frame_f frame_g post p1 p2) /// Logical precondition for subtyping relation for Steel computation.
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Steel.Effect.fsti" }
[ { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
req_f: Steel.Effect.Common.req_t pre_f -> ens_f: Steel.Effect.Common.ens_t pre_f a post_f -> req_g: Steel.Effect.Common.req_t pre_g -> ens_g: Steel.Effect.Common.ens_t pre_g a post_g -> _: Prims.squash (Steel.Effect.Common.can_be_split_dep pr pre_g (Steel.Effect.Common.star pre_f frame)) -> _: Prims.squash (Steel.Effect.Common.equiv_forall post_g (fun x -> Steel.Effect.Common.star (post_f x) frame)) -> Prims.pure_pre
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.vprop", "Prims.prop", "Prims.squash", "Steel.Effect.Common.can_be_split_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.equiv_forall", "FStar.Tactics.Effect.rewrite_with_tactic", "Steel.Effect.Common.vc_norm", "Prims.l_and", "Prims.l_Forall", "Steel.Effect.Common.hmem", "Prims.l_imp", "Steel.Effect.Common.mk_rmem", "Steel.Effect.Common.focus_rmem", "Prims.unit", "Steel.Effect.Common.can_be_split_trans", "Steel.Effect.Common.frame_equalities", "Prims.pure_pre" ]
[]
false
false
false
false
false
let subcomp_pre (#a: Type) (#pre_f: pre_t) (#post_f: post_t a) (req_f: req_t pre_f) (ens_f: ens_t pre_f a post_f) (#pre_g: pre_t) (#post_g: post_t a) (req_g: req_t pre_g) (ens_g: ens_t pre_g a post_g) (#frame: vprop) (#pr: prop) (_: squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) : pure_pre =
T.rewrite_with_tactic vc_norm (squash ((forall (h0: hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0: hmem pre_g) (x: a) (h1: hmem (post_g x)). (pr ==> (can_be_split_trans (post_g x) ((post_f x) `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) ((post_f x) `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1))))))
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_le_uint32
val bn_from_bytes_le_uint32:bn_from_bytes_le_st U32
val bn_from_bytes_le_uint32:bn_from_bytes_le_st U32
let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 86, "end_line": 139, "start_col": 0, "start_line": 139 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Convert.bn_from_bytes_le_st Lib.IntTypes.U32
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Convert.mk_bn_from_bytes_le", "Lib.IntTypes.U32" ]
[]
false
false
false
true
false
let bn_from_bytes_le_uint32:bn_from_bytes_le_st U32 =
mk_bn_from_bytes_le #U32 false
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_le_uint64
val bn_from_bytes_le_uint64:bn_from_bytes_le_st U64
val bn_from_bytes_le_uint64:bn_from_bytes_le_st U64
let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 86, "end_line": 141, "start_col": 0, "start_line": 141 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Convert.bn_from_bytes_le_st Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Convert.mk_bn_from_bytes_le", "Lib.IntTypes.U64" ]
[]
false
false
false
true
false
let bn_from_bytes_le_uint64:bn_from_bytes_le_st U64 =
mk_bn_from_bytes_le #U64 false
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_be_uint32
val bn_from_bytes_be_uint32:bn_from_bytes_be_st U32
val bn_from_bytes_be_uint32:bn_from_bytes_be_st U32
let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 86, "end_line": 91, "start_col": 0, "start_line": 91 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Convert.bn_from_bytes_be_st Lib.IntTypes.U32
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Convert.mk_bn_from_bytes_be", "Lib.IntTypes.U32" ]
[]
false
false
false
true
false
let bn_from_bytes_be_uint32:bn_from_bytes_be_st U32 =
mk_bn_from_bytes_be #U32 false
false
LowStar.RVector.fst
LowStar.RVector.insert_copy
val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v))))
val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v))))
let insert_copy #a #rst #rg cp rv v = let hh0 = HST.get () in rv_elems_inv_live_region hh0 rv 0ul (V.size_of rv); let nrid = HST.new_region (V.frameOf rv) in let nv = rg_alloc rg nrid in let hh1 = HST.get () in Rgl?.r_sep rg v loc_none hh0 hh1; rv_inv_preserved rv loc_none hh0 hh1; as_seq_preserved rv loc_none hh0 hh1; Cpy?.copy cp (Rgl?.state rg) v nv; let hh2 = HST.get () in rv_loc_elems_each_disj hh2 rv 0ul (V.size_of rv) nrid; rv_inv_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; as_seq_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; insert rv nv
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 873, "start_col": 0, "start_line": 857 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx)) #reset-options "--z3rlimit 20" let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx) val alloc_rid: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc_rid #a #rst rg len rid = let vec = V.alloc_rid len (rg_dummy rg) rid in alloc_ #a #rst #rg vec len; V.loc_vector_within_included vec 0ul len; vec val alloc_reserve: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = 0ul /\ S.equal (as_seq h1 rv) S.empty /\ Set.equal (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ B.fresh_loc (V.loc_vector rv) h0 h1)) let alloc_reserve #a #rst rg len rid = V.alloc_reserve len (rg_dummy rg) rid val alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ HS.fresh_region (V.frameOf rv) h0 h1 /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc #a #rst rg len = let nrid = HST.new_region HS.root in alloc_rid rg len nrid val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) #reset-options "--z3rlimit 20" let insert #a #rst #rg rv v = let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; // Correctness assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cp: LowStar.RVector.copyable a rg -> rv: LowStar.RVector.rvector rg {Prims.op_Negation (LowStar.Vector.is_full rv)} -> v: a -> FStar.HyperStack.ST.ST (LowStar.RVector.rvector rg)
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.copyable", "LowStar.RVector.rvector", "Prims.b2t", "Prims.op_Negation", "LowStar.Vector.is_full", "LowStar.RVector.insert", "Prims.unit", "LowStar.RVector.as_seq_preserved_", "LowStar.Monotonic.Buffer.loc_all_regions_from", "LowStar.RVector.rv_inv_preserved_", "LowStar.RVector.rv_loc_elems_each_disj", "FStar.UInt32.__uint_to_t", "LowStar.Vector.size_of", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.RVector.__proj__Cpy__item__copy", "LowStar.Regional.__proj__Rgl__item__state", "LowStar.RVector.as_seq_preserved", "LowStar.Monotonic.Buffer.loc_none", "LowStar.RVector.rv_inv_preserved", "LowStar.Regional.__proj__Rgl__item__r_sep", "LowStar.Regional.rg_alloc", "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.new_region", "LowStar.Vector.frameOf", "LowStar.RVector.rv_elems_inv_live_region" ]
[]
false
true
false
false
false
let insert_copy #a #rst #rg cp rv v =
let hh0 = HST.get () in rv_elems_inv_live_region hh0 rv 0ul (V.size_of rv); let nrid = HST.new_region (V.frameOf rv) in let nv = rg_alloc rg nrid in let hh1 = HST.get () in Rgl?.r_sep rg v loc_none hh0 hh1; rv_inv_preserved rv loc_none hh0 hh1; as_seq_preserved rv loc_none hh0 hh1; Cpy?.copy cp (Rgl?.state rg) v nv; let hh2 = HST.get () in rv_loc_elems_each_disj hh2 rv 0ul (V.size_of rv) nrid; rv_inv_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; as_seq_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; insert rv nv
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_be_uint64
val bn_from_bytes_be_uint64:bn_from_bytes_be_st U64
val bn_from_bytes_be_uint64:bn_from_bytes_be_st U64
let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 86, "end_line": 92, "start_col": 0, "start_line": 92 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Convert.bn_from_bytes_be_st Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Convert.mk_bn_from_bytes_be", "Lib.IntTypes.U64" ]
[]
false
false
false
true
false
let bn_from_bytes_be_uint64:bn_from_bytes_be_st U64 =
mk_bn_from_bytes_be #U64 false
false
Steel.Effect.fsti
Steel.Effect.if_then_else_ens
val if_then_else_ens (#a: Type) (#pre_f #pre_g: pre_t) (#post_f #post_g: post_t a) (#frame_f #frame_g: vprop) (#pr: prop) (s1: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (s2: squash (equiv_forall (fun x -> (post_f x) `star` frame_f) (fun x -> (post_g x) `star` frame_g))) (ens_then: ens_t pre_f a post_f) (ens_else: ens_t pre_g a post_g) (p: Type0) : ens_t (pre_f `star` frame_f) a (fun x -> (post_f x) `star` frame_f)
val if_then_else_ens (#a: Type) (#pre_f #pre_g: pre_t) (#post_f #post_g: post_t a) (#frame_f #frame_g: vprop) (#pr: prop) (s1: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (s2: squash (equiv_forall (fun x -> (post_f x) `star` frame_f) (fun x -> (post_g x) `star` frame_g))) (ens_then: ens_t pre_f a post_f) (ens_else: ens_t pre_g a post_g) (p: Type0) : ens_t (pre_f `star` frame_f) a (fun x -> (post_f x) `star` frame_f)
let if_then_else_ens (#a:Type) (#pre_f:pre_t) (#pre_g:pre_t) (#post_f:post_t a) (#post_g:post_t a) (#frame_f #frame_g:vprop) (#pr:prop) (s1: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (s2: squash (equiv_forall (fun x -> post_f x `star` frame_f) (fun x -> post_g x `star` frame_g))) (ens_then:ens_t pre_f a post_f) (ens_else:ens_t pre_g a post_g) (p:Type0) : ens_t (pre_f `star` frame_f) a (fun x -> post_f x `star` frame_f) = fun h0 x h1 -> pr /\ ( can_be_split_trans (pre_f `star` frame_f) (pre_g `star` frame_g) pre_g; can_be_split_trans (post_f x `star` frame_f) (post_g x `star` frame_g) (post_g x); (p ==> ens_then (focus_rmem h0 pre_f) x (focus_rmem h1 (post_f x))) /\ ((~ p) ==> ens_else (focus_rmem h0 pre_g) x (focus_rmem h1 (post_g x))))
{ "file_name": "lib/steel/Steel.Effect.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 76, "end_line": 226, "start_col": 0, "start_line": 214 }
(* 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.Effect open Steel.Memory module Mem = Steel.Memory module FExt = FStar.FunctionalExtensionality open FStar.Ghost module T = FStar.Tactics include Steel.Effect.Common /// This module defines the main Steel effect, with requires and ensures predicates operating on /// selectors, which will be discharged by SMT #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" (* Defining the Steel effect with selectors *) /// The underlying representation of Steel computations. /// The framed bit indicates whether this computation has already been framed. This corresponds to the |- and |-_F modalities /// in the ICFP21 paper val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:req_t pre) (ens:ens_t pre a post) : Type u#2 /// Logical precondition of the return combinator unfold let return_req (p:vprop) : req_t p = fun _ -> True /// Logical postcondition of the return combinator: /// The returned value [r] corresponds to the value passed to the return [x], /// and return leaves selectors of all resources in [p] unchanged unfold let return_ens (a:Type) (x:a) (p:a -> vprop) : ens_t (p x) a p = fun (h0:rmem (p x)) (r:a) (h1:rmem (p r)) -> r == x /\ frame_equalities (p x) h0 (focus_rmem h1 (p x)) /// Monadic return combinator for the Steel effect. It is parametric in the postcondition /// The vprop precondition is annotated with the return_pre predicate to enable special handling, /// as explained in Steel.Effect.Common val return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : repr a true (return_pre (p x)) p (return_req (p x)) (return_ens a x p) /// Logical precondition for the composition (bind) of two Steel computations: /// The postcondition of the first computation must imply the precondition of the second computation, /// and also ensure that any equalities abducted during frame inference inside the predicate [pr] are satisfied unfold let bind_req (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#pr:a -> prop) (req_g:(x:a -> req_t (pre_g x))) (frame_f:vprop) (frame_g:a -> vprop) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) : req_t (pre_f `star` frame_f) = fun m0 -> req_f (focus_rmem m0 pre_f) /\ (forall (x:a) (h1:hmem (post_f x `star` frame_f)). (ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f)) ==> pr x /\ (can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); (req_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)))) /// Logical postcondition for the composition (bind) of two Steel computations: /// The precondition of the first computation was satisfied in the initial state, and there /// exists an intermediate state where the two-state postcondition of the first computation was /// satisfied, and which yields the validity of the two-state postcondition of the second computation /// on the final state [m2] with the returned value [y] /// Note that the ensures for the bind below asserts req_f /// This is not necessary, but an explicit assert may help the solver unfold let bind_ens (#a:Type) (#b:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:a -> pre_t) (#post_g:a -> post_t b) (#pr:a -> prop) (ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (frame_f:vprop) (frame_g:a -> vprop) (post:post_t b) (_:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (_:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) : ens_t (pre_f `star` frame_f) b post = fun m0 y m2 -> req_f (focus_rmem m0 pre_f) /\ (exists (x:a) (h1:hmem (post_f x `star` frame_f)). pr x /\ ( can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (pre_g x); can_be_split_trans (post_f x `star` frame_f) (pre_g x `star` frame_g x) (frame_g x); can_be_split_trans (post y) (post_g x y `star` frame_g x) (post_g x y); can_be_split_trans (post y) (post_g x y `star` frame_g x) (frame_g x); frame_equalities frame_f (focus_rmem m0 frame_f) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) frame_f) /\ frame_equalities (frame_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (frame_g x)) (focus_rmem m2 (frame_g x)) /\ ens_f (focus_rmem m0 pre_f) x (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (post_f x)) /\ (ens_g x) (focus_rmem (mk_rmem (post_f x `star` frame_f) h1) (pre_g x)) y (focus_rmem m2 (post_g x y)))) /// Steel effect combinator to compose two Steel computations /// Separation logic VCs are squashed goals passed as implicits, annotated with the framing_implicit /// attribute. This indicates that they will be discharged by the tactic in Steel.Effect.Common /// Requires/ensures logical VCs are defined using weakest preconditions combinators defined above, /// and discharged by SMT. val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(x:a -> req_t (pre_g x))) (#[@@@ framing_implicit] ens_g:(x:a -> ens_t (pre_g x) b (post_g x))) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req req_f ens_f req_g frame_f frame_g p1) (bind_ens req_f ens_f ens_g frame_f frame_g post p1 p2) /// Logical precondition for subtyping relation for Steel computation. unfold let subcomp_pre (#a:Type) (#pre_f:pre_t) (#post_f:post_t a) (req_f:req_t pre_f) (ens_f:ens_t pre_f a post_f) (#pre_g:pre_t) (#post_g:post_t a) (req_g:req_t pre_g) (ens_g:ens_t pre_g a post_g) (#frame:vprop) (#pr:prop) (_:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (_:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) : pure_pre // The call to with_tactic allows us to reduce VCs in a controlled way, once all // uvars have been resolved. // To ensure an SMT-friendly encoding of the VC, it needs to be encapsulated in a squash call = T.rewrite_with_tactic vc_norm (squash ( (forall (h0:hmem pre_g). req_g (mk_rmem pre_g h0) ==> pr /\ (can_be_split_trans pre_g (pre_f `star` frame) pre_f; req_f (focus_rmem (mk_rmem pre_g h0) pre_f))) /\ (forall (h0:hmem pre_g) (x:a) (h1:hmem (post_g x)). ( pr ==> ( can_be_split_trans (post_g x) (post_f x `star` frame) (post_f x); can_be_split_trans (pre_g) (pre_f `star` frame) frame; can_be_split_trans (post_g x) (post_f x `star` frame) frame; can_be_split_trans pre_g (pre_f `star` frame) pre_f; (req_g (mk_rmem pre_g h0) /\ ens_f (focus_rmem (mk_rmem pre_g h0) pre_f) x (focus_rmem (mk_rmem (post_g x) h1) (post_f x)) /\ frame_equalities frame (focus_rmem (mk_rmem pre_g h0) frame) (focus_rmem (mk_rmem (post_g x) h1) frame)) ==> ens_g (mk_rmem pre_g h0) x (mk_rmem (post_g x) h1)) )) )) /// Subtyping combinator for Steel computations. /// Computation [f] is given type `repr a framed_g pre_g post_g req_g ens_g`. /// As for bind, separation logic goals are encoded as squashed implicits which will be discharged /// by tactic, while logical requires/ensures operating on selectors are discharged by SMT val subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:req_t pre_f) (#[@@@ framing_implicit] ens_f:ens_t pre_f a post_f) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:req_t pre_g) (#[@@@ framing_implicit] ens_g:ens_t pre_g a post_g) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] pr : prop) (#[@@@ framing_implicit] p1:squash (can_be_split_dep pr pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires subcomp_pre req_f ens_f req_g ens_g p1 p2) (ensures fun _ -> True) /// Logical precondition for the if_then_else combinator unfold let if_then_else_req (#pre_f:pre_t) (#pre_g:pre_t) (#frame_f #frame_g:vprop) (#pr: prop) (s_pre: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (req_then:req_t pre_f) (req_else:req_t pre_g) (p:Type0) : req_t (pre_f `star` frame_f) = fun h -> pr /\ ( can_be_split_trans (pre_f `star` frame_f) (pre_g `star` frame_g) pre_g; (p ==> req_then (focus_rmem h pre_f)) /\ ((~ p) ==> req_else (focus_rmem h pre_g))) /// Logical postcondition for the if_then_else combinator
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Steel.Effect.fsti" }
[ { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: Prims.squash (Steel.Effect.Common.can_be_split_dep pr (Steel.Effect.Common.star pre_f frame_f) (Steel.Effect.Common.star pre_g frame_g)) -> s2: Prims.squash (Steel.Effect.Common.equiv_forall (fun x -> Steel.Effect.Common.star (post_f x) frame_f) (fun x -> Steel.Effect.Common.star (post_g x) frame_g)) -> ens_then: Steel.Effect.Common.ens_t pre_f a post_f -> ens_else: Steel.Effect.Common.ens_t pre_g a post_g -> p: Type0 -> Steel.Effect.Common.ens_t (Steel.Effect.Common.star pre_f frame_f) a (fun x -> Steel.Effect.Common.star (post_f x) frame_f)
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.vprop", "Prims.prop", "Prims.squash", "Steel.Effect.Common.can_be_split_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.equiv_forall", "Steel.Effect.Common.ens_t", "Steel.Effect.Common.rmem", "Prims.l_and", "Prims.l_imp", "Steel.Effect.Common.focus_rmem", "Prims.l_not", "Prims.unit", "Steel.Effect.Common.can_be_split_trans" ]
[]
false
false
false
false
false
let if_then_else_ens (#a: Type) (#pre_f #pre_g: pre_t) (#post_f #post_g: post_t a) (#frame_f #frame_g: vprop) (#pr: prop) (s1: squash (can_be_split_dep pr (pre_f `star` frame_f) (pre_g `star` frame_g))) (s2: squash (equiv_forall (fun x -> (post_f x) `star` frame_f) (fun x -> (post_g x) `star` frame_g))) (ens_then: ens_t pre_f a post_f) (ens_else: ens_t pre_g a post_g) (p: Type0) : ens_t (pre_f `star` frame_f) a (fun x -> (post_f x) `star` frame_f) =
fun h0 x h1 -> pr /\ (can_be_split_trans (pre_f `star` frame_f) (pre_g `star` frame_g) pre_g; can_be_split_trans ((post_f x) `star` frame_f) ((post_g x) `star` frame_g) (post_g x); (p ==> ens_then (focus_rmem h0 pre_f) x (focus_rmem h1 (post_f x))) /\ ((~p) ==> ens_else (focus_rmem h0 pre_g) x (focus_rmem h1 (post_g x))))
false
Vale.AES.X64.GHash.fst
Vale.AES.X64.GHash.va_wpProof_Compute_ghash_incremental_register
val va_wpProof_Compute_ghash_incremental_register : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_ghash_incremental_register va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_ghash_incremental_register ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Compute_ghash_incremental_register : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_ghash_incremental_register va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_ghash_incremental_register ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Compute_ghash_incremental_register va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_ghash_incremental_register (va_code_Compute_ghash_incremental_register ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.AES.X64.GHash.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 258, "start_col": 0, "start_line": 248 }
module Vale.AES.X64.GHash open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GCTR_s open Vale.AES.GCM_helpers open Vale.Math.Poly2_s open Vale.Poly1305.Math open Vale.AES.X64.GF128_Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 30" //-- Compute_Y0 val va_code_Compute_Y0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Compute_Y0 () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CNil ()))) val va_codegen_success_Compute_Y0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_Y0 () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_Y0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_Y0 ())) = (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 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 84 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.Arch.Types.lemma_quad32_xor ()) (va_QEmpty (()))))) val va_lemma_Compute_Y0 : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Compute_Y0 ()) va_s0 /\ va_get_ok va_s0 /\ sse_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0))))) [@"opaque_to_smt"] let va_lemma_Compute_Y0 va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_Y0 va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_Y0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 77 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Compute_Y0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_xmm1:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 1 va_x_xmm1 va_s0) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0 ==> va_k va_sM (()))) val va_wpProof_Compute_Y0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Compute_Y0 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Compute_Y0 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Compute_Y0 (va_code_Compute_Y0 ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 1]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Compute_Y0 () : (va_quickCode unit (va_code_Compute_Y0 ())) = (va_QProc (va_code_Compute_Y0 ()) ([va_Mod_flags; va_Mod_xmm 1]) va_wp_Compute_Y0 va_wpProof_Compute_Y0) //-- //-- ReduceMul128_LE val va_code_ReduceMul128_LE : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_ReduceMul128_LE () = (va_Block (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CCons (va_code_ReduceMulRev128 ()) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_CNil ()))))) val va_codegen_success_ReduceMul128_LE : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_ReduceMul128_LE () = (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_ReduceMulRev128 ()) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_ReduceMul128_LE (va_mods:va_mods_t) (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (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 104 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 105 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMulRev128 a b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 106 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 1) (va_op_xmm_xmm 8)) (va_QEmpty (())))))) val va_lemma_ReduceMul128_LE : va_b0:va_code -> va_s0:va_state -> a:poly -> b:poly -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_ReduceMul128_LE ()) va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) /\ va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_ReduceMul128_LE va_b0 va_s0 a b = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok] in let va_qc = va_qcode_ReduceMul128_LE va_mods a b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceMul128_LE ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 87 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 102 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_ReduceMul128_LE (a:poly) (b:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ Vale.Math.Poly2_s.degree a <= 127 /\ Vale.Math.Poly2_s.degree b <= 127 /\ va_get_xmm 1 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 a) /\ va_get_xmm 2 va_s0 == Vale.AES.GF128_s.gf128_to_quad32 b /\ va_get_xmm 8 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051) /\ (forall (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) . let va_sM = va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl va_s0))))))) in va_get_ok va_sM /\ va_get_xmm 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GF128_s.gf128_to_quad32 (Vale.AES.GF128_s.gf128_mul a b)) ==> va_k va_sM (()))) val va_wpProof_ReduceMul128_LE : a:poly -> b:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_ReduceMul128_LE a b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_ReduceMul128_LE a b va_s0 va_k = let (va_sM, va_f0) = va_lemma_ReduceMul128_LE (va_code_ReduceMul128_LE ()) va_s0 a b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_ReduceMul128_LE (a:poly) (b:poly) : (va_quickCode unit (va_code_ReduceMul128_LE ())) = (va_QProc (va_code_ReduceMul128_LE ()) ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_reg64 rR12; va_Mod_flags]) (va_wp_ReduceMul128_LE a b) (va_wpProof_ReduceMul128_LE a b)) //-- //-- Compute_ghash_incremental_register [@ "opaque_to_smt" va_qattr] let va_code_Compute_ghash_incremental_register () = (va_Block (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (va_CCons (va_code_ReduceMul128_LE ()) (va_CNil ()))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Compute_ghash_incremental_register () = (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_ReduceMul128_LE ()) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_Compute_ghash_incremental_register (va_mods:va_mods_t) : (va_quickCode unit (va_code_Compute_ghash_incremental_register ())) = (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 124 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 125 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 2) (va_op_xmm_xmm 11)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 127 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_quick_ReduceMul128_LE (Vale.AES.GF128_s.gf128_of_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 1 va_s))) (Vale.AES.GF128_s.gf128_of_quad32 (va_get_xmm 11 va_s))) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 128 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (fun (_:unit) -> Vale.AES.GHash.ghash_incremental_reveal ()) (va_QEmpty (()))))))) [@"opaque_to_smt"] let va_lemma_Compute_ghash_incremental_register va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1; va_Mod_ok] in let va_qc = va_qcode_Compute_ghash_incremental_register va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Compute_ghash_incremental_register ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 109 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 122 column 89 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GHash.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.GHash.ghash_incremental (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_sM)) (va_get_xmm 1 va_s0) (FStar.Seq.Base.create #quad32 1 (va_get_xmm 2 va_s0)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_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.X64.GHash.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR12", "Vale.X64.QuickCode.va_Mod_flags", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.GHash.va_lemma_Compute_ghash_incremental_register", "Vale.AES.X64.GHash.va_code_Compute_ghash_incremental_register" ]
[]
false
false
false
false
false
let va_wpProof_Compute_ghash_incremental_register va_s0 va_k =
let va_sM, va_f0 = va_lemma_Compute_ghash_incremental_register (va_code_Compute_ghash_incremental_register ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_xmm 1 va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([ va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 1 ]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
LowStar.RVector.fst
LowStar.RVector.assign
val assign: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> // rv_inv h0 rv /\ rv_itself_inv h0 rv /\ rv_elems_inv h0 rv 0ul i /\ rv_elems_inv h0 rv (i + 1ul) (V.size_of rv) /\ elems_reg h0 rv /\ V.forall_ h0 rv 0ul i (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ V.forall_ h0 rv (i + 1ul) (V.size_of rv) (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv i (i + 1ul)) h0 h1 /\ rv_inv h1 rv /\ V.get h1 rv i == v /\ S.equal (as_seq h1 rv) (S.append (as_seq_sub h0 rv 0ul i) (S.cons (Rgl?.r_repr rg h0 v) (as_seq_sub h0 rv (i + 1ul) (V.size_of rv))))))
val assign: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> // rv_inv h0 rv /\ rv_itself_inv h0 rv /\ rv_elems_inv h0 rv 0ul i /\ rv_elems_inv h0 rv (i + 1ul) (V.size_of rv) /\ elems_reg h0 rv /\ V.forall_ h0 rv 0ul i (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ V.forall_ h0 rv (i + 1ul) (V.size_of rv) (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv i (i + 1ul)) h0 h1 /\ rv_inv h1 rv /\ V.get h1 rv i == v /\ S.equal (as_seq h1 rv) (S.append (as_seq_sub h0 rv 0ul i) (S.cons (Rgl?.r_repr rg h0 v) (as_seq_sub h0 rv (i + 1ul) (V.size_of rv))))))
let assign #a #rst #rg rv i v = let hh0 = HST.get () in V.assign rv i v; let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v i); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i + 1) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v i) (V.loc_vector rv) hh0 hh1; rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1; Rgl?.r_sep rg v (V.loc_vector rv) hh0 hh1; // Correctness rs_loc_elems_parent_disj rg (V.as_seq hh1 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); as_seq_seq_preserved rg (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 929, "start_col": 0, "start_line": 903 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx)) #reset-options "--z3rlimit 20" let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx) val alloc_rid: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc_rid #a #rst rg len rid = let vec = V.alloc_rid len (rg_dummy rg) rid in alloc_ #a #rst #rg vec len; V.loc_vector_within_included vec 0ul len; vec val alloc_reserve: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = 0ul /\ S.equal (as_seq h1 rv) S.empty /\ Set.equal (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ B.fresh_loc (V.loc_vector rv) h0 h1)) let alloc_reserve #a #rst rg len rid = V.alloc_reserve len (rg_dummy rg) rid val alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ HS.fresh_region (V.frameOf rv) h0 h1 /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc #a #rst rg len = let nrid = HST.new_region HS.root in alloc_rid rg len nrid val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) #reset-options "--z3rlimit 20" let insert #a #rst #rg rv v = let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; // Correctness assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv val insert_copy: #a:Type0 -> #rst:Type -> #rg:regional rst a -> cp:copyable #rst a rg -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.disjoint (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_rvector rv) h0 h1 /\ rv_inv h1 irv /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v)))) let insert_copy #a #rst #rg cp rv v = let hh0 = HST.get () in rv_elems_inv_live_region hh0 rv 0ul (V.size_of rv); let nrid = HST.new_region (V.frameOf rv) in let nv = rg_alloc rg nrid in let hh1 = HST.get () in Rgl?.r_sep rg v loc_none hh0 hh1; rv_inv_preserved rv loc_none hh0 hh1; as_seq_preserved rv loc_none hh0 hh1; Cpy?.copy cp (Rgl?.state rg) v nv; let hh2 = HST.get () in rv_loc_elems_each_disj hh2 rv 0ul (V.size_of rv) nrid; rv_inv_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; as_seq_preserved_ rv (loc_all_regions_from false nrid) hh1 hh2; insert rv nv val assign: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> v:a -> HST.ST unit (requires (fun h0 -> // rv_inv h0 rv /\ rv_itself_inv h0 rv /\ rv_elems_inv h0 rv 0ul i /\ rv_elems_inv h0 rv (i + 1ul) (V.size_of rv) /\ elems_reg h0 rv /\ V.forall_ h0 rv 0ul i (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ V.forall_ h0 rv (i + 1ul) (V.size_of rv) (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)) /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv))) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv i (i + 1ul)) h0 h1 /\ rv_inv h1 rv /\ V.get h1 rv i == v /\ S.equal (as_seq h1 rv) (S.append (as_seq_sub h0 rv 0ul i) (S.cons (Rgl?.r_repr rg h0 v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rv: LowStar.RVector.rvector rg -> i: LowStar.Vector.uint32_t{i < LowStar.Vector.size_of rv} -> v: a -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Vector.uint32_t", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Unsigned", "FStar.Integers.W32", "LowStar.Vector.size_of", "LowStar.RVector.as_seq_seq_preserved", "LowStar.Vector.as_seq", "FStar.UInt32.v", "LowStar.Vector.loc_vector", "Prims.unit", "LowStar.RVector.rs_loc_elems_parent_disj", "LowStar.Vector.frameOf", "LowStar.Regional.__proj__Rgl__item__r_sep", "LowStar.RVector.rs_elems_inv_preserved", "FStar.Integers.op_Plus", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Vector.assign" ]
[]
false
true
false
false
false
let assign #a #rst #rg rv i v =
let hh0 = HST.get () in V.assign rv i v; let hh1 = HST.get () in rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v i); rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i + 1) (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v i) (V.loc_vector rv) hh0 hh1; rs_elems_inv_preserved rg (V.as_seq hh0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1; Rgl?.r_sep rg v (V.loc_vector rv) hh0 hh1; rs_loc_elems_parent_disj rg (V.as_seq hh1 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); as_seq_seq_preserved rg (V.as_seq hh1 rv) 0 (U32.v (V.size_of rv)) (V.loc_vector rv) hh0 hh1
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_be_st
val bn_from_bytes_be_st : t: Hacl.Bignum.Definitions.limb_t -> Type0
let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b))
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 63, "start_col": 0, "start_line": 56 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t))))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Convert.bn_from_bytes_be" ]
[]
false
false
false
true
true
let bn_from_bytes_be_st (t: limb_t) =
len: size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b: lbuffer uint8 len -> res: lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b))
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_be
val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t
val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t
let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 100, "start_col": 0, "start_line": 97 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Convert.bn_from_bytes_be_st t
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Convert.bn_from_bytes_be_uint32", "Hacl.Bignum.Convert.bn_from_bytes_be_uint64", "Hacl.Bignum.Convert.bn_from_bytes_be_st" ]
[]
false
false
false
false
false
let bn_from_bytes_be #t =
match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_le_st
val bn_from_bytes_le_st : t: Hacl.Bignum.Definitions.limb_t -> Type0
let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b))
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 111, "start_col": 0, "start_line": 104 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Convert.bn_from_bytes_le" ]
[]
false
false
false
true
true
let bn_from_bytes_le_st (t: limb_t) =
len: size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b: lbuffer uint8 len -> res: lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b))
false
LowStar.RVector.fst
LowStar.RVector.alloc_
val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx))
val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx))
let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx)
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 740, "start_col": 0, "start_line": 714 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rv: LowStar.RVector.rvector rg -> cidx: LowStar.Vector.uint32_t{cidx <= LowStar.Vector.size_of rv} -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[ "" ]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Vector.uint32_t", "Prims.b2t", "FStar.Integers.op_Less_Equals", "FStar.Integers.Unsigned", "FStar.Integers.W32", "LowStar.Vector.size_of", "Prims.op_Equality", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Prims.unit", "Prims.bool", "LowStar.Vector.loc_vector_within_union_rev", "LowStar.Vector.forall2_extend", "FStar.Integers.op_Subtraction", "FStar.Monotonic.HyperHeap.disjoint", "LowStar.Regional.__proj__Rgl__item__region_of", "LowStar.Regional.__proj__Rgl__item__r_sep", "LowStar.Vector.get", "LowStar.Vector.loc_vector_within", "LowStar.Vector.loc_vector_within_included", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.RVector.alloc_", "LowStar.Vector.assign", "LowStar.Regional.rg_alloc", "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.new_region", "LowStar.Vector.frameOf" ]
[ "recursion" ]
false
true
false
false
false
let rec alloc_ #a #rst #rg rv cidx =
let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx)
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_le
val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t
val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t
let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 149, "start_col": 0, "start_line": 146 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Convert.bn_from_bytes_le_st t
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Convert.bn_from_bytes_le_uint32", "Hacl.Bignum.Convert.bn_from_bytes_le_uint64", "Hacl.Bignum.Convert.bn_from_bytes_le_st" ]
[]
false
false
false
false
false
let bn_from_bytes_le #t =
match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64
false
LowStar.RVector.fst
LowStar.RVector.insert
val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v))))
val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v))))
let insert #a #rst #rg rv v = let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in // Safety rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; // Correctness assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv
{ "file_name": "ulib/LowStar.RVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 841, "start_col": 0, "start_line": 815 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.RVector open FStar.Classical open FStar.Integers open LowStar.Modifies open LowStar.Regional open LowStar.Vector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module U32 = FStar.UInt32 /// Utilities /// A `regional` type `a` is also `copyable` when there exists a copy operator /// that guarantees the same representation between `src` and `dst`. /// For instance, the `copy` operation for `B.buffer a` is `B.blit`. /// /// Here, no reference at run-time is kept to the state argument of the /// regional; conceivably, the caller will already have some reference handy to /// the instance of the regional class and can retrieve the parameter from /// there. inline_for_extraction noeq type copyable (#rst:Type) (a:Type0) (rg:regional rst a) = | Cpy: copy: (s:rst{s==Rgl?.state rg} -> src:a -> dst:a -> HST.ST unit (requires (fun h0 -> rg_inv rg h0 src /\ rg_inv rg h0 dst /\ HS.disjoint (Rgl?.region_of rg src) (Rgl?.region_of rg dst))) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (Rgl?.region_of rg dst)) h0 h1 /\ rg_inv rg h1 dst /\ Rgl?.r_repr rg h1 dst == Rgl?.r_repr rg h0 src))) -> copyable a rg // rst: regional state type rvector (#a:Type0) (#rst:Type) (rg:regional rst a) = V.vector a val loc_rvector: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> GTot loc let loc_rvector #a #rst #rg rv = loc_all_regions_from false (V.frameOf rv) /// The invariant of `rvector` // Here we will define the invariant for `rvector #a` that contains // the invariant for each element and some more about the vector itself. val rs_elems_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_inv #a #rst rg h rs i j = V.forall_seq rs i j (rg_inv rg h) val rv_elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_inv #a #rst #rg h rv i j = rs_elems_inv rg h (V.as_seq h rv) (U32.v i) (U32.v j) val elems_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_inv #a #rst #rg h rv = rv_elems_inv h rv 0ul (V.size_of rv) val rs_elems_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot Type0 let rs_elems_reg #a #rst rg rs prid i j = V.forall_seq rs i j (fun v -> HS.extends (Rgl?.region_of rg v) prid) /\ V.forall2_seq rs i j (fun v1 v2 -> HS.disjoint (Rgl?.region_of rg v1) (Rgl?.region_of rg v2)) val rv_elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot Type0 let rv_elems_reg #a #rst #rg h rv i j = rs_elems_reg rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val elems_reg: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let elems_reg #a #rst #rg h rv = rv_elems_reg h rv 0ul (V.size_of rv) val rv_itself_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_itself_inv #a #rst #rg h rv = V.live h rv /\ V.freeable rv /\ HST.is_eternal_region (V.frameOf rv) // This is the invariant of `rvector`. val rv_inv: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> GTot Type0 let rv_inv #a #rst #rg h rv = elems_inv h rv /\ elems_reg h rv /\ rv_itself_inv h rv val rs_elems_inv_live_region: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_inv rg h rs i j)) (ensures (V.forall_seq rs i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rec rs_elems_inv_live_region #a #rst rg h rs i j = if i = j then () else (Rgl?.r_inv_reg rg h (S.index rs (j - 1)); rs_elems_inv_live_region rg h rs i (j - 1)) val rv_elems_inv_live_region: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_inv h rv i j)) (ensures (V.forall_ h rv i j (fun r -> HS.live_region h (Rgl?.region_of rg r)))) let rv_elems_inv_live_region #a #rst #rg h rv i j = rs_elems_inv_live_region rg h (V.as_seq h rv) (U32.v i) (U32.v j) /// Utilities for fine-grained region control val rs_loc_elem: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat{i < S.length rs} -> GTot loc let rs_loc_elem #a #rst rg rs i = loc_all_regions_from false (Rgl?.region_of rg (S.index rs i)) val rs_loc_elems: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> GTot loc (decreases j) let rec rs_loc_elems #a #rst rg rs i j = if i = j then loc_none else loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1)) val rv_loc_elems: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> GTot loc let rv_loc_elems #a #rst #rg h rv i j = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v j) val rv_loc_elem: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> GTot loc let rv_loc_elem #a #rst #rg h rv i = rs_loc_elems rg (V.as_seq h rv) (U32.v i) (U32.v i+1) // Properties about inclusion of locations val rs_loc_elems_rec_inverse: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i < j && j <= S.length rs} -> Lemma (requires true) (ensures (rs_loc_elems rg rs i j == loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) j))) (decreases j) let rec rs_loc_elems_rec_inverse #a #rst rg rs i j = if i + 1 = j then () else (assert (rs_loc_elems rg rs i j == loc_union (rs_loc_elems rg rs i (j - 1)) (rs_loc_elem rg rs (j - 1))); assert (rs_loc_elems rg rs (i + 1) j == loc_union (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))); rs_loc_elems_rec_inverse rg rs i (j - 1); assert (rs_loc_elems rg rs i j == loc_union (loc_union (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1))) (rs_loc_elem rg rs (j - 1))); loc_union_assoc (rs_loc_elem rg rs i) (rs_loc_elems rg rs (i + 1) (j - 1)) (rs_loc_elem rg rs (j - 1))) val rs_loc_elems_includes: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> Lemma (loc_includes (rs_loc_elems rg rs i j) (rs_loc_elem rg rs k)) let rec rs_loc_elems_includes #a #rst rg rs i j k = if k = j - 1 then () else rs_loc_elems_includes #a #rst rg rs i (j - 1) k val loc_all_exts_from: preserve_liveness: bool -> r: HS.rid -> GTot loc let loc_all_exts_from preserve_liveness r = B.loc_regions preserve_liveness (Set.intersect (HS.mod_set (Set.singleton r)) (Set.complement (Set.singleton r))) val rs_loc_elem_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat{i < S.length rs} -> Lemma (requires (HS.extends (Rgl?.region_of rg (S.index rs i)) prid)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elem rg rs i))) let rs_loc_elem_included #a #rst rg rs prid i = () val rs_loc_elems_included: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_includes (loc_all_exts_from false prid) (rs_loc_elems rg rs i j))) (decreases j) let rec rs_loc_elems_included #a #rst rg rs prid i j = if i = j then () else (rs_loc_elem_included rg rs prid (j - 1); rs_loc_elems_included rg rs prid i (j - 1)) val rv_loc_elems_included: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_includes (loc_all_exts_from false (V.frameOf rv)) (rv_loc_elems h rv i j))) let rv_loc_elems_included #a #rst #rg h rv i j = rs_loc_elems_included rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) // Properties about disjointness of locations val rs_loc_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k:nat{i <= k && k < j} -> l:nat{i <= l && l < j && k <> l} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj #a #rst rg rs prid i j k l = () val rs_loc_elem_disj_forall: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures ( forall (k:nat{i <= k && k < j}). forall (l:nat{i <= l && l < j && k <> l}). loc_disjoint (rs_loc_elem rg rs k) (rs_loc_elem rg rs l))) let rs_loc_elem_disj_forall #a #rst rg rs prid i j = () val rs_loc_elems_elem_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l:nat{i <= l && l < j && (l < k1 || k2 <= l)} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elem rg rs l))) (decreases k2) let rec rs_loc_elems_elem_disj #a #rst rg rs prid i j k1 k2 l = if k1 = k2 then () else (rs_loc_elem_disj rg rs prid i j (k2 - 1) l; rs_loc_elems_elem_disj rg rs prid i j k1 (k2 - 1) l) val rs_loc_elems_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> k1:nat{i <= k1} -> k2:nat{k1 <= k2 && k2 <= j} -> l1:nat{i <= l1} -> l2:nat{l1 <= l2 && l2 <= j} -> Lemma (requires (rs_elems_reg rg rs prid i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rs_loc_elems rg rs k1 k2) (rs_loc_elems rg rs l1 l2))) (decreases k2) let rec rs_loc_elems_disj #a #rst rg rs prid i j k1 k2 l1 l2 = if k1 = k2 then () else (rs_loc_elems_elem_disj rg rs prid i j l1 l2 (k2 - 1); rs_loc_elems_disj rg rs prid i j k1 (k2 - 1) l1 l2) val rv_loc_elems_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> k1:uint32_t{i <= k1} -> k2:uint32_t{k1 <= k2 && k2 <= j} -> l1:uint32_t{i <= l1} -> l2:uint32_t{l1 <= l2 && l2 <= j} -> Lemma (requires (rv_elems_reg h rv i j /\ (k2 <= l1 || l2 <= k1))) (ensures (loc_disjoint (rv_loc_elems h rv k1 k2) (rv_loc_elems h rv l1 l2))) let rv_loc_elems_disj #a #rst #rg h rv i j k1 k2 l1 l2 = rs_loc_elems_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) (U32.v k1) (U32.v k2) (U32.v l1) (U32.v l2) val rs_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> prid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (rs_elems_reg rg rs prid i j)) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_region_only false prid))) (decreases j) let rec rs_loc_elems_parent_disj #a #rst rg rs prid i j = if i = j then () else rs_loc_elems_parent_disj rg rs prid i (j - 1) val rv_loc_elems_parent_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> Lemma (requires (rv_elems_reg h rv i j)) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_region_only false (V.frameOf rv)))) let rv_loc_elems_parent_disj #a #rst #rg h rv i j = rs_loc_elems_parent_disj rg (V.as_seq h rv) (V.frameOf rv) (U32.v i) (U32.v j) val rs_loc_elems_each_disj: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> drid:HS.rid -> i:nat -> j:nat{i <= j && j <= S.length rs} -> Lemma (requires (V.forall_seq rs i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rs_loc_elems rg rs i j) (loc_all_regions_from false drid))) (decreases j) let rec rs_loc_elems_each_disj #a #rst rg rs drid i j = if i = j then () else rs_loc_elems_each_disj rg rs drid i (j - 1) val rv_loc_elems_each_disj: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> drid:HS.rid -> Lemma (requires (V.forall_ h rv i j (fun r -> HS.disjoint (Rgl?.region_of rg r) drid))) (ensures (loc_disjoint (rv_loc_elems h rv i j) (loc_all_regions_from false drid))) let rv_loc_elems_each_disj #a #rst #rg h rv i j drid = rs_loc_elems_each_disj rg (V.as_seq h rv) drid (U32.v i) (U32.v j) // Preservation based on disjointness val rv_loc_elems_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ loc_disjoint p (V.loc_vector_within rv i j) /\ modifies p h0 h1)) (ensures (rv_loc_elems h0 rv i j == rv_loc_elems h1 rv i j)) (decreases (U32.v j)) let rec rv_loc_elems_preserved #a #rst #rg rv i j p h0 h1 = if i = j then () else (V.loc_vector_within_includes rv i j (j - 1ul) j; V.get_preserved rv (j - 1ul) p h0 h1; assert (V.get h0 rv (j - 1ul) == V.get h1 rv (j - 1ul)); V.loc_vector_within_includes rv i j i (j - 1ul); rv_loc_elems_preserved rv i (j - 1ul) p h0 h1) val rs_elems_inv_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv rg h1 rs i j)) (decreases j) let rec rs_elems_inv_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val rv_elems_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (V.loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ modifies p h0 h1)) (ensures (rv_elems_inv h1 rv i j)) let rv_elems_inv_preserved #a #rst #rg rv i j p h0 h1 = rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val rv_inv_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) let rv_inv_preserved_ #a #rst #rg rv p h0 h1 = rv_elems_inv_preserved #a #rst #rg rv 0ul (V.size_of rv) p h0 h1 // The first core lemma of `rvector` val rv_inv_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv h1 rv)) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let rv_inv_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); rv_inv_preserved_ rv p h0 h1 val rv_inv_preserved_int: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t{i < V.size_of rv} -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ modifies (loc_all_regions_from false (Rgl?.region_of rg (V.get h0 rv i))) h0 h1 /\ rg_inv rg h1 (V.get h1 rv i))) (ensures (rv_inv h1 rv)) let rv_inv_preserved_int #a #rst #rg rv i h0 h1 = rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) 0 (U32.v i) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) 0 (U32.v i) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1; rs_loc_elems_elem_disj rg (V.as_seq h0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)) (U32.v i + 1) (U32.v (V.size_of rv)) (U32.v i); rs_elems_inv_preserved rg (V.as_seq h0 rv) (U32.v i + 1) (U32.v (V.size_of rv)) (loc_all_regions_from false (Rgl?.region_of rg (V.get h1 rv i))) h0 h1 /// Representation val as_seq_seq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = j - i}) (decreases j) let rec as_seq_seq #a #rst rg h rs i j = if i = j then S.empty else S.snoc (as_seq_seq rg h rs i (j - 1)) (Rgl?.r_repr rg h (S.index rs (j - 1))) val as_seq_sub: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg -> i:uint32_t -> j:uint32_t{ i <= j /\ j <= V.size_of rv /\ rv_elems_inv h rv i j} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v j - U32.v i}) (decreases (U32.v j)) let as_seq_sub #a #rst #rg h rv i j = as_seq_seq rg h (V.as_seq h rv) (U32.v i) (U32.v j) val as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> GTot (s:S.seq (Rgl?.repr rg){S.length s = U32.v (V.size_of rv)}) let as_seq #a #rst #rg h rv = as_seq_sub h rv 0ul (V.size_of rv) val as_seq_sub_as_seq: #a:Type0 -> #rst:Type -> #rg:regional rst a -> h:HS.mem -> rv:rvector rg{rv_inv h rv} -> Lemma (S.equal (as_seq_sub h rv 0ul (V.size_of rv)) (as_seq h rv)) [SMTPat (as_seq_sub h rv 0ul (V.size_of rv))] let as_seq_sub_as_seq #a #rst #rg h rv = () val as_seq_seq_index: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{k < j - i} -> Lemma (requires true) (ensures (S.index (as_seq_seq rg h rs i j) k == Rgl?.r_repr rg h (S.index rs (i + k)))) (decreases j) [SMTPat (S.index (as_seq_seq rg h rs i j) k)] let rec as_seq_seq_index #a #rst rg h rs i j k = if i = j then () else if k = j - i - 1 then () else as_seq_seq_index rg h rs i (j - 1) k val as_seq_seq_eq: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs1:S.seq a -> rs2:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs1 /\ rs_elems_inv rg h rs1 i j} -> k:nat -> l:nat{k <= l /\ l <= S.length rs2 /\ rs_elems_inv rg h rs2 k l} -> Lemma (requires (S.equal (S.slice rs1 i j) (S.slice rs2 k l))) (ensures (S.equal (as_seq_seq rg h rs1 i j) (as_seq_seq rg h rs2 k l))) let as_seq_seq_eq #a #rst rg h rs1 rs2 i j k l = assert (forall (a:nat{a < j - i}). S.index (as_seq_seq rg h rs1 i j) a == Rgl?.r_repr rg h (S.index rs1 (i + a))); assert (forall (a:nat{a < l - k}). S.index (as_seq_seq rg h rs2 k l) a == Rgl?.r_repr rg h (S.index rs2 (k + a))); assert (S.length (S.slice rs1 i j) = j - i); assert (S.length (S.slice rs2 k l) = l - k); assert (forall (a:nat{a < j - i}). S.index (S.slice rs1 i j) a == S.index (S.slice rs2 k l) a); assert (forall (a:nat{a < j - i}). S.index rs1 (i + a) == S.index rs2 (k + a)) val as_seq_seq_slice: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat -> l:nat{k <= l && l <= j - i} -> Lemma (S.equal (S.slice (as_seq_seq rg h rs i j) k l) (as_seq_seq rg h (S.slice rs (i + k) (i + l)) 0 (l - k))) #reset-options "--z3rlimit 10" let rec as_seq_seq_slice #a #rst rg h rs i j k l = if k = l then () else (as_seq_seq_slice rg h rs i j k (l - 1); as_seq_seq_index rg h rs i j (l - 1); as_seq_seq_eq rg h (S.slice rs (i + k) (i + l - 1)) (S.slice rs (i + k) (i + l)) 0 (l - k - 1) 0 (l - k - 1)) val as_seq_seq_upd: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> rs:S.seq a -> i:nat -> j:nat{ i <= j /\ j <= S.length rs /\ rs_elems_inv rg h rs i j} -> k:nat{i <= k && k < j} -> v:a{rg_inv rg h v} -> Lemma (S.equal (as_seq_seq rg h (S.upd rs k v) i j) (S.upd (as_seq_seq rg h rs i j) (k - i) (Rgl?.r_repr rg h v))) let rec as_seq_seq_upd #a #rst rg h rs i j k v = if i = j then () else if k = j - 1 then () else as_seq_seq_upd rg h rs i (j - 1) k v // Preservation based on disjointness val as_seq_seq_preserved: #a:Type0 -> #rst:Type -> rg:regional rst a -> rs:S.seq a -> i:nat -> j:nat{i <= j && j <= S.length rs} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rs_elems_inv rg h0 rs i j /\ loc_disjoint p (rs_loc_elems rg rs i j) /\ modifies p h0 h1)) (ensures (rs_elems_inv_preserved rg rs i j p h0 h1; S.equal (as_seq_seq rg h0 rs i j) (as_seq_seq rg h1 rs i j))) let rec as_seq_seq_preserved #a #rst rg rs i j p h0 h1 = if i = j then () else (rs_elems_inv_preserved rg rs i (j - 1) p h0 h1; as_seq_seq_preserved rg rs i (j - 1) p h0 h1; Rgl?.r_sep rg (S.index rs (j - 1)) p h0 h1) val as_seq_sub_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> i:uint32_t -> j:uint32_t{i <= j && j <= V.size_of rv} -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (V.live h0 rv /\ rv_elems_inv h0 rv i j /\ loc_disjoint p (rv_loc_elems h0 rv i j) /\ loc_disjoint p (V.loc_vector rv) /\ modifies p h0 h1)) (ensures (rv_elems_inv_preserved rv i j p h0 h1; S.equal (as_seq_sub h0 rv i j) (as_seq_sub h1 rv i j))) let as_seq_sub_preserved #a #rst #rg rv i j p h0 h1 = as_seq_seq_preserved rg (V.as_seq h0 rv) (U32.v i) (U32.v j) p h0 h1 val as_seq_preserved_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_vector rv) /\ loc_disjoint p (rv_loc_elems h0 rv 0ul (V.size_of rv)) /\ modifies p h0 h1)) (ensures (rv_inv_preserved_ rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) let as_seq_preserved_ #a #rst #rg rv p h0 h1 = as_seq_sub_preserved rv 0ul (V.size_of rv) p h0 h1 // The second core lemma of `rvector` val as_seq_preserved: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (rv_inv h0 rv /\ loc_disjoint p (loc_rvector rv) /\ modifies p h0 h1)) (ensures (rv_inv_preserved rv p h0 h1; S.equal (as_seq h0 rv) (as_seq h1 rv))) [SMTPat (rv_inv h0 rv); SMTPat (loc_disjoint p (loc_rvector rv)); SMTPat (modifies p h0 h1)] let as_seq_preserved #a #rst #rg rv p h0 h1 = assert (loc_includes (loc_rvector rv) (V.loc_vector rv)); rv_loc_elems_included h0 rv 0ul (V.size_of rv); assert (loc_includes (loc_rvector rv) (rv_loc_elems h0 rv 0ul (V.size_of rv))); as_seq_preserved_ rv p h0 h1 /// Construction val alloc_empty: #a:Type0 -> #rst:Type -> rg:regional rst a -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 bv h1 -> h0 == h1 /\ V.size_of bv = 0ul)) let alloc_empty #a #rst rg = V.alloc_empty a val alloc_: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg -> cidx:uint32_t{cidx <= V.size_of rv} -> HST.ST unit (requires (fun h0 -> rv_itself_inv h0 rv)) (ensures (fun h0 _ h1 -> modifies (V.loc_vector_within rv 0ul cidx) h0 h1 /\ rv_itself_inv h1 rv /\ rv_elems_inv h1 rv 0ul cidx /\ rv_elems_reg h1 rv 0ul cidx /\ S.equal (as_seq_sub h1 rv 0ul cidx) (S.create (U32.v cidx) (Ghost.reveal (Rgl?.irepr rg))) /\ // the loop invariant for this function V.forall_ h1 rv 0ul cidx (fun r -> HS.fresh_region (Rgl?.region_of rg r) h0 h1 /\ Rgl?.r_alloc_p rg r) /\ Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)))) (decreases (U32.v cidx)) #reset-options "--z3rlimit 20" let rec alloc_ #a #rst #rg rv cidx = let hh0 = HST.get () in if cidx = 0ul then () else (let nrid = HST.new_region (V.frameOf rv) in let v = rg_alloc rg nrid in let hh1 = HST.get () in V.assign rv (cidx - 1ul) v; let hh2 = HST.get () in V.loc_vector_within_included rv (cidx - 1ul) cidx; Rgl?.r_sep rg (V.get hh2 rv (cidx - 1ul)) (V.loc_vector_within rv (cidx - 1ul) cidx) hh1 hh2; alloc_ rv (cidx - 1ul); let hh3 = HST.get () in V.loc_vector_within_included rv 0ul (cidx - 1ul); Rgl?.r_sep rg (V.get hh3 rv (cidx - 1ul)) (V.loc_vector_within rv 0ul (cidx - 1ul)) hh2 hh3; V.forall2_extend hh3 rv 0ul (cidx - 1ul) (fun r1 r2 -> HS.disjoint (Rgl?.region_of rg r1) (Rgl?.region_of rg r2)); V.loc_vector_within_union_rev rv 0ul cidx) val alloc_rid: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc_rid #a #rst rg len rid = let vec = V.alloc_rid len (rg_dummy rg) rid in alloc_ #a #rst #rg vec len; V.loc_vector_within_included vec 0ul len; vec val alloc_reserve: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> rid:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ V.frameOf rv = rid /\ V.size_of rv = 0ul /\ S.equal (as_seq h1 rv) S.empty /\ Set.equal (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ B.fresh_loc (V.loc_vector rv) h0 h1)) let alloc_reserve #a #rst rg len rid = V.alloc_reserve len (rg_dummy rg) rid val alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> len:uint32_t{len > 0ul} -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 rv h1 -> modifies (V.loc_vector rv) h0 h1 /\ rv_inv h1 rv /\ HS.fresh_region (V.frameOf rv) h0 h1 /\ V.size_of rv = len /\ V.forall_all h1 rv (fun r -> Rgl?.r_alloc_p rg r) /\ S.equal (as_seq h1 rv) (S.create (U32.v len) (Ghost.reveal (Rgl?.irepr rg))))) let alloc #a #rst rg len = let nrid = HST.new_region HS.root in alloc_rid rg len nrid val insert: #a:Type0 -> #rst:Type -> #rg:regional rst a -> rv:rvector rg{not (V.is_full rv)} -> v:a -> HST.ST (rvector rg) (requires (fun h0 -> rv_inv h0 rv /\ rg_inv rg h0 v /\ HS.extends (Rgl?.region_of rg v) (V.frameOf rv) /\ V.forall_all h0 rv (fun b -> HS.disjoint (Rgl?.region_of rg b) (Rgl?.region_of rg v)))) (ensures (fun h0 irv h1 -> V.size_of irv = V.size_of rv + 1ul /\ V.frameOf rv = V.frameOf irv /\ modifies (loc_union (V.loc_addr_of_vector rv) (V.loc_vector irv)) h0 h1 /\ rv_inv h1 irv /\ V.get h1 irv (V.size_of rv) == v /\ S.equal (as_seq h1 irv) (S.snoc (as_seq h0 rv) (Rgl?.r_repr rg h0 v))))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.RVector.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Modifies", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rv: LowStar.RVector.rvector rg {Prims.op_Negation (LowStar.Vector.is_full rv)} -> v: a -> FStar.HyperStack.ST.ST (LowStar.RVector.rvector rg)
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "Prims.b2t", "Prims.op_Negation", "LowStar.Vector.is_full", "Prims.unit", "LowStar.RVector.as_seq_seq_slice", "LowStar.Vector.as_seq", "FStar.UInt32.v", "LowStar.Vector.size_of", "LowStar.RVector.as_seq_seq_preserved", "LowStar.Monotonic.Buffer.loc_region_only", "LowStar.Vector.frameOf", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "LowStar.Regional.__proj__Rgl__item__r_sep", "LowStar.RVector.rs_elems_inv_preserved", "LowStar.RVector.rs_loc_elems_parent_disj", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Vector.vector", "LowStar.Vector.insert" ]
[]
false
true
false
false
false
let insert #a #rst #rg rv v =
let hh0 = HST.get () in let irv = V.insert rv v in let hh1 = HST.get () in rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv)); rs_elems_inv_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; Rgl?.r_sep rg v (loc_region_only false (V.frameOf rv)) hh0 hh1; assert (S.equal (V.as_seq hh0 rv) (S.slice (V.as_seq hh1 irv) 0 (U32.v (V.size_of rv)))); as_seq_seq_preserved rg (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (loc_region_only false (V.frameOf rv)) hh0 hh1; as_seq_seq_slice rg hh1 (V.as_seq hh1 irv) 0 (U32.v (V.size_of irv)) 0 (U32.v (V.size_of rv)); irv
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_be
val bn_to_bytes_be: #t:_ -> len:_ -> bn_to_bytes_be_st t len
val bn_to_bytes_be: #t:_ -> len:_ -> bn_to_bytes_be_st t len
let bn_to_bytes_be #t = match t with | U32 -> bn_to_bytes_be_uint32 | U64 -> bn_to_bytes_be_uint64
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 226, "start_col": 0, "start_line": 223 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b)) inline_for_extraction noextract let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_be: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_be_st t len let mk_bn_to_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; bn_to_bytes_be_ bnLen b res end else begin HyperStack.ST.break_vc (); bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end; pop_frame () [@CInline] let bn_to_bytes_be_uint32 len : bn_to_bytes_be_st U32 len = mk_bn_to_bytes_be #U32 false len let bn_to_bytes_be_uint64 len : bn_to_bytes_be_st U64 len = mk_bn_to_bytes_be #U64 false len inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes t * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes t))) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.Convert.bn_to_bytes_be_st t len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Convert.bn_to_bytes_be_uint32", "Hacl.Bignum.Convert.bn_to_bytes_be_uint64", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Convert.bn_to_bytes_be_st" ]
[]
false
false
false
false
false
let bn_to_bytes_be #t =
match t with | U32 -> bn_to_bytes_be_uint32 | U64 -> bn_to_bytes_be_uint64
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_uint
val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x)
val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x)
let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 33, "start_col": 0, "start_line": 31 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t{0 < Lib.IntTypes.v len} -> x: Hacl.Bignum.Definitions.limb t -> b: Hacl.Bignum.Definitions.lbignum t len -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.Definitions.lbignum", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t", "Prims.unit", "Lib.Buffer.memset", "Lib.IntTypes.uint", "Lib.IntTypes.SEC" ]
[]
false
true
false
false
false
let bn_from_uint #t len x b =
memset b (uint #t 0) len; b.(0ul) <- x
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_be_uint64
val bn_to_bytes_be_uint64 (len: _) : bn_to_bytes_be_st U64 len
val bn_to_bytes_be_uint64 (len: _) : bn_to_bytes_be_st U64 len
let bn_to_bytes_be_uint64 len : bn_to_bytes_be_st U64 len = mk_bn_to_bytes_be #U64 false len
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 92, "end_line": 218, "start_col": 0, "start_line": 218 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b)) inline_for_extraction noextract let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_be: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_be_st t len let mk_bn_to_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; bn_to_bytes_be_ bnLen b res end else begin HyperStack.ST.break_vc (); bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end; pop_frame () [@CInline]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes Lib.IntTypes.U64 * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes Lib.IntTypes.U64))) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.Convert.bn_to_bytes_be_st Lib.IntTypes.U64 len
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Lib.IntTypes.U64", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Convert.mk_bn_to_bytes_be", "Hacl.Bignum.Convert.bn_to_bytes_be_st" ]
[]
false
false
false
false
false
let bn_to_bytes_be_uint64 len : bn_to_bytes_be_st U64 len =
mk_bn_to_bytes_be #U64 false len
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_le
val bn_to_bytes_le: #t:_ -> len:_ -> bn_to_bytes_le_st t len
val bn_to_bytes_le: #t:_ -> len:_ -> bn_to_bytes_le_st t len
let bn_to_bytes_le #t = match t with | U32 -> bn_to_bytes_le_uint32 | U64 -> bn_to_bytes_le_uint64
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 281, "start_col": 0, "start_line": 278 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b)) inline_for_extraction noextract let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_be: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_be_st t len let mk_bn_to_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; bn_to_bytes_be_ bnLen b res end else begin HyperStack.ST.break_vc (); bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end; pop_frame () [@CInline] let bn_to_bytes_be_uint32 len : bn_to_bytes_be_st U32 len = mk_bn_to_bytes_be #U32 false len let bn_to_bytes_be_uint64 len : bn_to_bytes_be_st U64 len = mk_bn_to_bytes_be #U64 false len inline_for_extraction noextract val bn_to_bytes_be: #t:_ -> len:_ -> bn_to_bytes_be_st t len let bn_to_bytes_be #t = match t with | U32 -> bn_to_bytes_be_uint32 | U64 -> bn_to_bytes_be_uint64 inline_for_extraction noextract let bn_to_bytes_le_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_le: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_le_st t len let mk_bn_to_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; uints_to_bytes_le bnLen res b end else begin uints_to_bytes_le bnLen tmp b; copy res (sub tmp 0ul len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in uints_to_bytes_le bnLen tmp b; copy res (sub tmp 0ul len) end; pop_frame () [@CInline] let bn_to_bytes_le_uint32 len : bn_to_bytes_le_st U32 len = mk_bn_to_bytes_le #U32 false len [@CInline] let bn_to_bytes_le_uint64 len : bn_to_bytes_le_st U64 len = mk_bn_to_bytes_le #U64 false len inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes t * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes t))) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.Convert.bn_to_bytes_le_st t len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Convert.bn_to_bytes_le_uint32", "Hacl.Bignum.Convert.bn_to_bytes_le_uint64", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Convert.bn_to_bytes_le_st" ]
[]
false
false
false
false
false
let bn_to_bytes_le #t =
match t with | U32 -> bn_to_bytes_le_uint32 | U64 -> bn_to_bytes_le_uint64
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_be_uint32
val bn_to_bytes_be_uint32 (len: _) : bn_to_bytes_be_st U32 len
val bn_to_bytes_be_uint32 (len: _) : bn_to_bytes_be_st U32 len
let bn_to_bytes_be_uint32 len : bn_to_bytes_be_st U32 len = mk_bn_to_bytes_be #U32 false len
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 92, "end_line": 217, "start_col": 0, "start_line": 217 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b)) inline_for_extraction noextract let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_be: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_be_st t len let mk_bn_to_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; bn_to_bytes_be_ bnLen b res end else begin HyperStack.ST.break_vc (); bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end; pop_frame ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes Lib.IntTypes.U32 * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes Lib.IntTypes.U32))) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.Convert.bn_to_bytes_be_st Lib.IntTypes.U32 len
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Convert.mk_bn_to_bytes_be", "Hacl.Bignum.Convert.bn_to_bytes_be_st" ]
[]
false
false
false
false
false
let bn_to_bytes_be_uint32 len : bn_to_bytes_be_st U32 len =
mk_bn_to_bytes_be #U32 false len
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_le_uint64
val bn_to_bytes_le_uint64 (len: _) : bn_to_bytes_le_st U64 len
val bn_to_bytes_le_uint64 (len: _) : bn_to_bytes_le_st U64 len
let bn_to_bytes_le_uint64 len : bn_to_bytes_le_st U64 len = mk_bn_to_bytes_le #U64 false len
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 92, "end_line": 273, "start_col": 0, "start_line": 273 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b)) inline_for_extraction noextract let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_be: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_be_st t len let mk_bn_to_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; bn_to_bytes_be_ bnLen b res end else begin HyperStack.ST.break_vc (); bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end; pop_frame () [@CInline] let bn_to_bytes_be_uint32 len : bn_to_bytes_be_st U32 len = mk_bn_to_bytes_be #U32 false len let bn_to_bytes_be_uint64 len : bn_to_bytes_be_st U64 len = mk_bn_to_bytes_be #U64 false len inline_for_extraction noextract val bn_to_bytes_be: #t:_ -> len:_ -> bn_to_bytes_be_st t len let bn_to_bytes_be #t = match t with | U32 -> bn_to_bytes_be_uint32 | U64 -> bn_to_bytes_be_uint64 inline_for_extraction noextract let bn_to_bytes_le_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_le: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_le_st t len let mk_bn_to_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; uints_to_bytes_le bnLen res b end else begin uints_to_bytes_le bnLen tmp b; copy res (sub tmp 0ul len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in uints_to_bytes_le bnLen tmp b; copy res (sub tmp 0ul len) end; pop_frame () [@CInline] let bn_to_bytes_le_uint32 len : bn_to_bytes_le_st U32 len = mk_bn_to_bytes_le #U32 false len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes Lib.IntTypes.U64 * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes Lib.IntTypes.U64))) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.Convert.bn_to_bytes_le_st Lib.IntTypes.U64 len
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Lib.IntTypes.U64", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Convert.mk_bn_to_bytes_le", "Hacl.Bignum.Convert.bn_to_bytes_le_st" ]
[]
false
false
false
false
false
let bn_to_bytes_le_uint64 len : bn_to_bytes_le_st U64 len =
mk_bn_to_bytes_le #U64 false len
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_be_st
val bn_to_bytes_be_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes t * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes t))) <= Lib.IntTypes.max_size_t } -> Type0
let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b))
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 60, "end_line": 183, "start_col": 0, "start_line": 176 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes t * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes t))) <= Lib.IntTypes.max_size_t } -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.lseq", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Convert.bn_to_bytes_be" ]
[]
false
false
false
false
true
let bn_to_bytes_be_st (t: limb_t) (len: size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) =
b: lbignum t (blocks len (size (numbytes t))) -> res: lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b))
false
Hacl.Impl.Ed25519.Ladder.fst
Hacl.Impl.Ed25519.Ladder.convert_scalar
val convert_scalar: scalar:lbuffer uint8 32ul -> bscalar:lbuffer uint64 4ul -> Stack unit (requires fun h -> live h scalar /\ live h bscalar /\ disjoint scalar bscalar) (ensures fun h0 _ h1 -> modifies (loc bscalar) h0 h1 /\ BD.bn_v h1 bscalar == BSeq.nat_from_bytes_le (as_seq h0 scalar))
val convert_scalar: scalar:lbuffer uint8 32ul -> bscalar:lbuffer uint64 4ul -> Stack unit (requires fun h -> live h scalar /\ live h bscalar /\ disjoint scalar bscalar) (ensures fun h0 _ h1 -> modifies (loc bscalar) h0 h1 /\ BD.bn_v h1 bscalar == BSeq.nat_from_bytes_le (as_seq h0 scalar))
let convert_scalar scalar bscalar = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #U64 32 (as_seq h0 scalar); Hacl.Bignum.Convert.mk_bn_from_bytes_le true 32ul scalar bscalar
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.Ladder.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 66, "end_line": 63, "start_col": 0, "start_line": 60 }
module Hacl.Impl.Ed25519.Ladder module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module BSeq = Lib.ByteSequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Bignum.Definitions module SD = Hacl.Spec.Bignum.Definitions module S = Spec.Ed25519 open Hacl.Impl.Ed25519.PointConstants include Hacl.Impl.Ed25519.Group include Hacl.Ed25519.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 20ul 16ul = [@inline_let] let len = 20ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_ed25519_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 20ul 32ul = [@inline_let] let len = 20ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_ed25519_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) = v table_len); BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract val convert_scalar: scalar:lbuffer uint8 32ul -> bscalar:lbuffer uint64 4ul -> Stack unit (requires fun h -> live h scalar /\ live h bscalar /\ disjoint scalar bscalar) (ensures fun h0 _ h1 -> modifies (loc bscalar) h0 h1 /\ BD.bn_v h1 bscalar == BSeq.nat_from_bytes_le (as_seq h0 scalar))
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.Group.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Ed25519.PrecompTable.fsti.checked", "Hacl.Bignum25519.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Ed25519.Ladder.fst" }
[ { "abbrev": false, "full_module": "Hacl.Ed25519.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519.PointConstants", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
scalar: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> bscalar: Lib.Buffer.lbuffer Lib.IntTypes.uint64 4ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint64", "Hacl.Bignum.Convert.mk_bn_from_bytes_le", "Lib.IntTypes.U64", "Prims.unit", "Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let convert_scalar scalar bscalar =
let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #U64 32 (as_seq h0 scalar); Hacl.Bignum.Convert.mk_bn_from_bytes_le true 32ul scalar bscalar
false
FStar.Int128.fst
FStar.Int128.v
val v (x:t) : Tot (int_t n)
val v (x:t) : Tot (int_t n)
let v x = x.v
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 32, "start_col": 0, "start_line": 32 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int128.t -> FStar.Int.int_t FStar.Int128.n
Prims.Tot
[ "total" ]
[]
[ "FStar.Int128.t", "FStar.Int128.__proj__Mk__item__v", "FStar.Int.int_t", "FStar.Int128.n" ]
[]
false
false
false
true
false
let v x =
x.v
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_le_uint32
val bn_to_bytes_le_uint32 (len: _) : bn_to_bytes_le_st U32 len
val bn_to_bytes_le_uint32 (len: _) : bn_to_bytes_le_st U32 len
let bn_to_bytes_le_uint32 len : bn_to_bytes_le_st U32 len = mk_bn_to_bytes_le #U32 false len
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 92, "end_line": 271, "start_col": 0, "start_line": 271 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b)) inline_for_extraction noextract let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_be: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_be_st t len let mk_bn_to_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; bn_to_bytes_be_ bnLen b res end else begin HyperStack.ST.break_vc (); bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end; pop_frame () [@CInline] let bn_to_bytes_be_uint32 len : bn_to_bytes_be_st U32 len = mk_bn_to_bytes_be #U32 false len let bn_to_bytes_be_uint64 len : bn_to_bytes_be_st U64 len = mk_bn_to_bytes_be #U64 false len inline_for_extraction noextract val bn_to_bytes_be: #t:_ -> len:_ -> bn_to_bytes_be_st t len let bn_to_bytes_be #t = match t with | U32 -> bn_to_bytes_be_uint32 | U64 -> bn_to_bytes_be_uint64 inline_for_extraction noextract let bn_to_bytes_le_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_le: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_le_st t len let mk_bn_to_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; uints_to_bytes_le bnLen res b end else begin uints_to_bytes_le bnLen tmp b; copy res (sub tmp 0ul len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in uints_to_bytes_le bnLen tmp b; copy res (sub tmp 0ul len) end; pop_frame ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes Lib.IntTypes.U32 * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes Lib.IntTypes.U32))) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.Convert.bn_to_bytes_le_st Lib.IntTypes.U32 len
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Convert.mk_bn_to_bytes_le", "Hacl.Bignum.Convert.bn_to_bytes_le_st" ]
[]
false
false
false
false
false
let bn_to_bytes_le_uint32 len : bn_to_bytes_le_st U32 len =
mk_bn_to_bytes_le #U32 false len
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_to_bytes_le_st
val bn_to_bytes_le_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes t * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes t))) <= Lib.IntTypes.max_size_t } -> Type0
let bn_to_bytes_le_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_le (v len) (as_seq h0 b))
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 60, "end_line": 237, "start_col": 0, "start_line": 230 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame () [@CInline] let bn_from_bytes_be_uint32 : bn_from_bytes_be_st U32 = mk_bn_from_bytes_be #U32 false let bn_from_bytes_be_uint64 : bn_from_bytes_be_st U64 = mk_bn_from_bytes_be #U64 false inline_for_extraction noextract val bn_from_bytes_be: #t:limb_t -> bn_from_bytes_be_st t let bn_from_bytes_be #t = match t with | U32 -> bn_from_bytes_be_uint32 | U64 -> bn_from_bytes_be_uint64 inline_for_extraction noextract let bn_from_bytes_le_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_le (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_from_bytes_le: #t:limb_t -> is_known_len:bool -> bn_from_bytes_le_st t let mk_bn_from_bytes_le #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then uints_from_bytes_le res b else begin let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp 0ul len b; uints_from_bytes_le res tmp end; pop_frame () [@CInline] let bn_from_bytes_le_uint32 : bn_from_bytes_le_st U32 = mk_bn_from_bytes_le #U32 false [@CInline] let bn_from_bytes_le_uint64 : bn_from_bytes_le_st U64 = mk_bn_from_bytes_le #U64 false inline_for_extraction noextract val bn_from_bytes_le: #t:limb_t -> bn_from_bytes_le_st t let bn_from_bytes_le #t = match t with | U32 -> bn_from_bytes_le_uint32 | U64 -> bn_from_bytes_le_uint64 inline_for_extraction noextract val bn_to_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbignum t len -> res:lbuffer uint8 (size (numbytes t) *! len) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be_ (v len) (as_seq h0 b)) let bn_to_bytes_be_ #t len b res = [@inline_let] let numb = size (numbytes t) in let h0 = ST.get () in [@ inline_let] let a_spec (i:nat{i <= v len}) = unit in [@ inline_let] let spec (h:mem) = S.bn_to_bytes_be_f (v len) (as_seq h b) in fill_blocks h0 numb len res a_spec (fun _ _ -> ()) (fun _ -> LowStar.Buffer.loc_none) spec (fun j -> uint_to_bytes_be (sub res (j *! numb) numb) b.(len -! j -! 1ul)); norm_spec [delta_only [`%S.bn_to_bytes_be_]] (S.bn_to_bytes_be_ (v len) (as_seq h0 b)) inline_for_extraction noextract let bn_to_bytes_be_st (t:limb_t) (len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) = b:lbignum t (blocks len (size (numbytes t))) -> res:lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract val mk_bn_to_bytes_be: #t:limb_t -> is_known_len:bool -> len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> bn_to_bytes_be_st t len let mk_bn_to_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in if tmpLen =. len then begin LowStar.Ignore.ignore tmp; bn_to_bytes_be_ bnLen b res end else begin HyperStack.ST.break_vc (); bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in bn_to_bytes_be_ bnLen b tmp; copy res (sub tmp (tmpLen -! len) len) end; pop_frame () [@CInline] let bn_to_bytes_be_uint32 len : bn_to_bytes_be_st U32 len = mk_bn_to_bytes_be #U32 false len let bn_to_bytes_be_uint64 len : bn_to_bytes_be_st U64 len = mk_bn_to_bytes_be #U64 false len inline_for_extraction noextract val bn_to_bytes_be: #t:_ -> len:_ -> bn_to_bytes_be_st t len let bn_to_bytes_be #t = match t with | U32 -> bn_to_bytes_be_uint32 | U64 -> bn_to_bytes_be_uint64
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.numbytes t * Lib.IntTypes.v (Hacl.Bignum.Definitions.blocks len (Lib.IntTypes.size (Lib.IntTypes.numbytes t))) <= Lib.IntTypes.max_size_t } -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.lseq", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Convert.bn_to_bytes_le" ]
[]
false
false
false
false
true
let bn_to_bytes_le_st (t: limb_t) (len: size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t}) =
b: lbignum t (blocks len (size (numbytes t))) -> res: lbuffer uint8 len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_to_bytes_le (v len) (as_seq h0 b))
false
Hacl.Impl.Ed25519.Ladder.fst
Hacl.Impl.Ed25519.Ladder.table_inv_w5
val table_inv_w5:BE.table_inv_t U64 20ul 32ul
val table_inv_w5:BE.table_inv_t U64 20ul 32ul
let table_inv_w5 : BE.table_inv_t U64 20ul 32ul = [@inline_let] let len = 20ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_ed25519_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) = v table_len); BE.table_inv_precomp len ctx_len k l table_len
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.Ladder.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 50, "start_col": 0, "start_line": 43 }
module Hacl.Impl.Ed25519.Ladder module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module BSeq = Lib.ByteSequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Bignum.Definitions module SD = Hacl.Spec.Bignum.Definitions module S = Spec.Ed25519 open Hacl.Impl.Ed25519.PointConstants include Hacl.Impl.Ed25519.Group include Hacl.Ed25519.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 20ul 16ul = [@inline_let] let len = 20ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_ed25519_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.Group.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Ed25519.PrecompTable.fsti.checked", "Hacl.Bignum25519.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Ed25519.Ladder.fst" }
[ { "abbrev": false, "full_module": "Hacl.Ed25519.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519.PointConstants", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (20ul <: FStar.UInt32.t) (32ul <: FStar.UInt32.t)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Impl.Exponentiation.table_inv_precomp", "Lib.IntTypes.U64", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.pow2", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.Ed25519.Group.mk_ed25519_concrete_ops" ]
[]
false
false
false
false
false
let table_inv_w5:BE.table_inv_t U64 20ul 32ul =
[@@ inline_let ]let len = 20ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_ed25519_concrete_ops in [@@ inline_let ]let l = 5ul in [@@ inline_let ]let table_len = 32ul in assert_norm (pow2 (v l) = v table_len); BE.table_inv_precomp len ctx_len k l table_len
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.bn_from_bytes_be_
val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b))
val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b))
let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t))))
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 102, "end_line": 52, "start_col": 0, "start_line": 47 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t{Lib.IntTypes.numbytes t * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Lib.IntTypes.size (Lib.IntTypes.numbytes t) *! len) -> res: Hacl.Bignum.Definitions.lbignum t len -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.max_size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Hacl.Bignum.Definitions.lbignum", "Lib.Buffer.fill", "Hacl.Bignum.Definitions.limb", "Prims.op_LessThan", "Lib.ByteBuffer.uint_from_bytes_be", "Lib.IntTypes.SEC", "Lib.IntTypes.uint_t", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.mk_int", "Lib.Buffer.sub", "Lib.IntTypes.op_Subtraction_Bang", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Convert.bn_from_bytes_be_f", "Lib.Buffer.as_seq", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let bn_from_bytes_be_ #t len b res =
let h0 = ST.get () in [@@ inline_let ]let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t))))
false
Hacl.Impl.Ed25519.Ladder.fst
Hacl.Impl.Ed25519.Ladder.table_inv_w4
val table_inv_w4:BE.table_inv_t U64 20ul 16ul
val table_inv_w4:BE.table_inv_t U64 20ul 16ul
let table_inv_w4 : BE.table_inv_t U64 20ul 16ul = [@inline_let] let len = 20ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_ed25519_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.Ladder.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 39, "start_col": 0, "start_line": 33 }
module Hacl.Impl.Ed25519.Ladder module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module BSeq = Lib.ByteSequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Bignum.Definitions module SD = Hacl.Spec.Bignum.Definitions module S = Spec.Ed25519 open Hacl.Impl.Ed25519.PointConstants include Hacl.Impl.Ed25519.Group include Hacl.Ed25519.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.Group.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Ed25519.PrecompTable.fsti.checked", "Hacl.Bignum25519.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Ed25519.Ladder.fst" }
[ { "abbrev": false, "full_module": "Hacl.Ed25519.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519.PointConstants", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (20ul <: FStar.UInt32.t) (16ul <: FStar.UInt32.t)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Impl.Exponentiation.table_inv_precomp", "Lib.IntTypes.U64", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.Ed25519.Group.mk_ed25519_concrete_ops" ]
[]
false
false
false
false
false
let table_inv_w4:BE.table_inv_t U64 20ul 16ul =
[@@ inline_let ]let len = 20ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_ed25519_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len
false
IMST.fst
IMST.st_post'
val st_post' : s: Type0 -> a: Type -> pre: Type -> Type
let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 74, "end_line": 29, "start_col": 0, "start_line": 29 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type0 -> a: Type -> pre: Type -> Type
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
true
let st_post' (s: Type0) (a pre: Type) =
a -> _: s{pre} -> GTot Type0
false
IMST.fst
IMST.st_pre
val st_pre : s: Type0 -> Type
let st_pre (s:Type0) = s -> GTot Type0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 28, "start_col": 0, "start_line": 28 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type0 -> Type
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
true
let st_pre (s: Type0) =
s -> GTot Type0
false
FStar.Int128.fst
FStar.Int128.zero
val zero : x:t{v x = 0}
val zero : x:t{v x = 0}
let zero = int_to_t 0
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 43, "start_col": 0, "start_line": 43 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int128.t{FStar.Int128.v x = 0}
Prims.Tot
[ "total" ]
[]
[ "FStar.Int128.int_to_t" ]
[]
false
false
false
false
false
let zero =
int_to_t 0
false
FStar.Int128.fst
FStar.Int128.add
val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c))
val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c))
let add a b = Mk (add (v a) (v b))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 49, "start_col": 0, "start_line": 49 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Int128.t -> b: FStar.Int128.t -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "FStar.Int128.Mk", "FStar.Int.add", "FStar.Int128.n", "FStar.Int128.v" ]
[]
false
false
false
false
false
let add a b =
Mk (add (v a) (v b))
false
FStar.Int128.fst
FStar.Int128.sub
val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c))
val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c))
let sub a b = Mk (sub (v a) (v b))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 51, "start_col": 0, "start_line": 51 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1 let add a b = Mk (add (v a) (v b))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Int128.t -> b: FStar.Int128.t -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "FStar.Int128.Mk", "FStar.Int.sub", "FStar.Int128.n", "FStar.Int128.v" ]
[]
false
false
false
false
false
let sub a b =
Mk (sub (v a) (v b))
false
IMST.fst
IMST.st_post
val st_post : s: Type0 -> a: Type -> Type
let st_post (s:Type0) (a:Type) = st_post_h' s a True
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 30, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type0 -> a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.st_post_h'", "Prims.l_True" ]
[]
false
false
false
true
true
let st_post (s: Type0) (a: Type) =
st_post_h' s a True
false
FStar.Int128.fst
FStar.Int128.one
val one : x:t{v x = 1}
val one : x:t{v x = 1}
let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 47, "start_col": 0, "start_line": 45 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int128.t{FStar.Int128.v x = 1}
Prims.Tot
[ "total" ]
[]
[ "FStar.Int128.int_to_t", "Prims.unit", "FStar.Math.Lemmas.pow2_lt_compat", "Prims.op_Subtraction", "FStar.Int128.n" ]
[]
false
false
false
false
false
let one =
FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1
false
Hacl.Bignum.Convert.fst
Hacl.Bignum.Convert.mk_bn_from_bytes_be
val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t
val mk_bn_from_bytes_be: #t:limb_t -> is_known_len:bool -> bn_from_bytes_be_st t
let mk_bn_from_bytes_be #t is_known_len len b res = push_frame (); if is_known_len then begin [@inline_let] let numb = size (numbytes t) in [@inline_let] let bnLen = blocks len numb in [@inline_let] let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else begin let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end end else begin [@inline_let] let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res end; pop_frame ()
{ "file_name": "code/bignum/Hacl.Bignum.Convert.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 87, "start_col": 0, "start_line": 68 }
module Hacl.Bignum.Convert open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Hacl.Spec.Bignum.Convert #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_from_uint: #t:limb_t -> len:size_t{0 < v len} -> x:limb t -> b:lbignum t len -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_from_uint (v len) x) let bn_from_uint #t len x b = memset b (uint #t 0) len; b.(0ul) <- x inline_for_extraction noextract val bn_from_bytes_be_: #t:limb_t -> len:size_t{numbytes t * v len <= max_size_t} -> b:lbuffer uint8 (size (numbytes t) *! len) -> res:lbignum t len -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be_ (v len) (as_seq h0 b)) let bn_from_bytes_be_ #t len b res = let h0 = ST.get () in [@inline_let] let spec h = S.bn_from_bytes_be_f (v len) (as_seq h b) in fill h0 len res spec (fun j -> uint_from_bytes_be (sub b ((len -! j -! 1ul) *! (size (numbytes t))) (size (numbytes t)))) inline_for_extraction noextract let bn_from_bytes_be_st (t:limb_t) = len:size_t{0 < v len /\ numbytes t * v (blocks len (size (numbytes t))) <= max_size_t} -> b:lbuffer uint8 len -> res:lbignum t (blocks len (size (numbytes t))) -> Stack unit (requires fun h -> live h b /\ live h res /\ disjoint res b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_from_bytes_be (v len) (as_seq h0 b)) inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Convert.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Convert", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
is_known_len: Prims.bool -> Hacl.Bignum.Convert.bn_from_bytes_be_st t
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Prims.bool", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.max_size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.IntTypes.op_Equals_Dot", "Hacl.Bignum.Convert.bn_from_bytes_be_", "Lib.Buffer.update_sub", "Lib.Buffer.MUT", "Lib.IntTypes.op_Subtraction_Bang", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.u8", "Lib.IntTypes.op_Star_Bang", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Hacl.Spec.Bignum.Definitions.blocks", "FStar.HyperStack.ST.push_frame" ]
[]
false
false
false
false
false
let mk_bn_from_bytes_be #t is_known_len len b res =
push_frame (); if is_known_len then [@@ inline_let ]let numb = size (numbytes t) in [@@ inline_let ]let bnLen = blocks len numb in [@@ inline_let ]let tmpLen = numb *! bnLen in if tmpLen =. len then bn_from_bytes_be_ bnLen b res else let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res else ([@@ inline_let ]let numb = size (numbytes t) in let bnLen = blocks len numb in let tmpLen = numb *! bnLen in let tmp = create tmpLen (u8 0) in update_sub tmp (tmpLen -! len) len b; bn_from_bytes_be_ bnLen tmp res); pop_frame ()
false
FStar.Int128.fst
FStar.Int128.int_to_t
val int_to_t: x:int_t n -> Pure t (requires True) (ensures (fun y -> v y = x))
val int_to_t: x:int_t n -> Pure t (requires True) (ensures (fun y -> v y = x))
let int_to_t x = Mk x
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 35, "start_col": 0, "start_line": 35 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int.int_t FStar.Int128.n -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int.int_t", "FStar.Int128.n", "FStar.Int128.Mk", "FStar.Int128.t" ]
[]
false
false
false
false
false
let int_to_t x =
Mk x
false
IMST.fst
IMST.st_return
val st_return : a: Type -> x: a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.logical
let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 36, "start_col": 0, "start_line": 35 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "IMST.st_post", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Prims.logical" ]
[]
false
false
false
true
true
let st_return (a: Type) (x: a) (s: Type0) (rel: preorder s) (post: st_post s a) (s0: s) =
forall v. v == x ==> post v s0
false
IMST.fst
IMST.st_wp
val st_wp : a: Type -> Type
let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s)
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 84, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.Pervasives.st_post_h", "FStar.Pervasives.st_pre_h" ]
[]
false
false
false
true
true
let st_wp (a: Type) =
s: Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s)
false
IMST.fst
IMST.st_bind
val st_bind : a: Type -> b: Type -> wp1: IMST.st_wp a -> wp2: (_: a -> IMST.st_wp b) -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s b -> s0: s -> Type0
let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 42, "start_col": 0, "start_line": 39 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: Type -> wp1: IMST.st_wp a -> wp2: (_: a -> IMST.st_wp b) -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s b -> s0: s -> Type0
Prims.Tot
[ "total" ]
[]
[ "IMST.st_wp", "FStar.Preorder.preorder", "IMST.st_post", "Prims.l_True" ]
[]
false
false
false
true
true
let st_bind (a b: Type) (wp1: st_wp a) (wp2: (a -> Tot (st_wp b))) (s: Type0) (rel: preorder s) (post: st_post s b) (s0: s) =
wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0
false
IMST.fst
IMST.st_stronger
val st_stronger : a: Type -> wp1: IMST.st_wp a -> wp2: IMST.st_wp a -> Prims.logical
let st_stronger (a:Type) (wp1:st_wp a) (wp2:st_wp a) = forall (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) . wp1 s rel p s0 ==> wp2 s rel p s0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 96, "end_line": 58, "start_col": 0, "start_line": 57 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0) unfold let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> wp1: IMST.st_wp a -> wp2: IMST.st_wp a -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "IMST.st_wp", "Prims.l_Forall", "FStar.Preorder.preorder", "IMST.st_post", "Prims.l_imp", "Prims.logical" ]
[]
false
false
false
true
true
let st_stronger (a: Type) (wp1 wp2: st_wp a) =
forall (s: Type0) (rel: preorder s) (p: st_post s a) (s0: s). wp1 s rel p s0 ==> wp2 s rel p s0
false
IMST.fst
IMST.st_if_then_else
val st_if_then_else : a: Type -> p: Type0 -> wp_then: IMST.st_wp a -> wp_else: IMST.st_wp a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.logical
let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0)
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 48, "start_col": 0, "start_line": 45 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> p: Type0 -> wp_then: IMST.st_wp a -> wp_else: IMST.st_wp a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "IMST.st_wp", "FStar.Preorder.preorder", "IMST.st_post", "Prims.l_ITE", "Prims.logical" ]
[]
false
false
false
true
true
let st_if_then_else (a p: Type) (wp_then wp_else: st_wp a) (s: Type0) (rel: preorder s) (post: st_post s a) (s0: s) =
l_ITE p (wp_then s rel post s0) (wp_else s rel post s0)
false
IMST.fst
IMST.lift_div_imst
val lift_div_imst : a: Type -> wp: Prims.pure_wp a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.pure_pre
let lift_div_imst (a:Type) (wp:pure_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = wp (fun x -> post x s0)
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 101, "start_col": 0, "start_line": 99 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0) unfold let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0 unfold let st_stronger (a:Type) (wp1:st_wp a) (wp2:st_wp a) = forall (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) . wp1 s rel p s0 ==> wp2 s rel p s0 unfold let st_close (a:Type) (b:Type) (wp:(b -> GTot (st_wp a))) (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) = forall x. wp x s rel p s0 unfold let st_trivial (a:Type) (wp:st_wp a) = forall s rel s0. wp s rel (fun _ _ -> True) s0 new_effect { IMST : result:Type -> wp:st_wp result -> Effect with //repr = s:Type0 -> preorder s -> s -> M (a * s) // - pi-types currently not supported by DM4F //repr' = s:Type0 -> rel:preorder s -> s0:s -> M (a * s1:s{rel s0 s1}) // - pi-types currently not supported by DM4F; // refinement types also currently not supported by DM4F return_wp = st_return ; bind_wp = st_bind ; if_then_else = st_if_then_else ; ite_wp = st_ite ; stronger = st_stronger ; close_wp = st_close ; trivial = st_trivial } // For effects where subtyping parameters is sound, e.g., // // exn:Type -> exns:set exn -> M (either a e:exn{mem e exns}) // // there is also the problem of needing to subtype postconditions according to the chosen (subset) order on exns. // // The precise typing would (highly likely) be needed to ensure that reification/reflection are sound. (* Standard lifting *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> wp: Prims.pure_wp a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.pure_pre
Prims.Tot
[ "total" ]
[]
[ "Prims.pure_wp", "FStar.Preorder.preorder", "IMST.st_post", "Prims.l_True", "Prims.pure_pre" ]
[]
false
false
false
true
false
let lift_div_imst (a: Type) (wp: pure_wp a) (s: Type0) (rel: preorder s) (post: st_post s a) (s0: s) =
wp (fun x -> post x s0)
false
IMST.fst
IMST.st_ite
val st_ite : a: Type -> wp: IMST.st_wp a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.logical
let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 54, "start_col": 0, "start_line": 51 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> wp: IMST.st_wp a -> s: Type0 -> rel: FStar.Preorder.preorder s -> post: IMST.st_post s a -> s0: s -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "IMST.st_wp", "FStar.Preorder.preorder", "IMST.st_post", "Prims.l_Forall", "Prims.l_imp", "Prims.guard_free", "Prims.logical" ]
[]
false
false
false
true
true
let st_ite (a: Type) (wp: st_wp a) (s: Type0) (rel: preorder s) (post: st_post s a) (s0: s) =
forall (k: st_post s a). (forall (x: a) (s1: s). {:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0
false
FStar.Int128.fst
FStar.Int128.rem
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires (size (v a / v b) n)) (ensures (fun c -> FStar.Int.mod (v a) (v b) = v c))
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires (size (v a / v b) n)) (ensures (fun c -> FStar.Int.mod (v a) (v b) = v c))
let rem a b = Mk (mod (v a) (v b))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 57, "start_col": 0, "start_line": 57 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1 let add a b = Mk (add (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let div a b = Mk (div (v a) (v b))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Int128.t -> b: FStar.Int128.t{FStar.Int128.v b <> 0} -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.Int128.v", "FStar.Int128.Mk", "FStar.Int.mod", "FStar.Int128.n" ]
[]
false
false
false
false
false
let rem a b =
Mk (mod (v a) (v b))
false
IMST.fst
IMST.st_trivial
val st_trivial : a: Type -> wp: IMST.st_wp a -> Prims.logical
let st_trivial (a:Type) (wp:st_wp a) = forall s rel s0. wp s rel (fun _ _ -> True) s0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 67, "start_col": 0, "start_line": 66 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0) unfold let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0 unfold let st_stronger (a:Type) (wp1:st_wp a) (wp2:st_wp a) = forall (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) . wp1 s rel p s0 ==> wp2 s rel p s0 unfold let st_close (a:Type) (b:Type) (wp:(b -> GTot (st_wp a))) (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) = forall x. wp x s rel p s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> wp: IMST.st_wp a -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "IMST.st_wp", "Prims.l_Forall", "FStar.Preorder.preorder", "Prims.l_True", "Prims.logical" ]
[]
false
false
false
true
true
let st_trivial (a: Type) (wp: st_wp a) =
forall s rel s0. wp s rel (fun _ _ -> True) s0
false
IMST.fst
IMST.st_close
val st_close : a: Type -> b: Type -> wp: (_: b -> Prims.GTot (IMST.st_wp a)) -> s: Type0 -> rel: FStar.Preorder.preorder s -> p: IMST.st_post s a -> s0: s -> Prims.logical
let st_close (a:Type) (b:Type) (wp:(b -> GTot (st_wp a))) (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) = forall x. wp x s rel p s0
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 63, "start_col": 0, "start_line": 61 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0) unfold let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0 unfold let st_stronger (a:Type) (wp1:st_wp a) (wp2:st_wp a) = forall (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) . wp1 s rel p s0 ==> wp2 s rel p s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: Type -> wp: (_: b -> Prims.GTot (IMST.st_wp a)) -> s: Type0 -> rel: FStar.Preorder.preorder s -> p: IMST.st_post s a -> s0: s -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "IMST.st_wp", "FStar.Preorder.preorder", "IMST.st_post", "Prims.l_Forall", "Prims.logical" ]
[]
false
false
false
false
true
let st_close (a b: Type) (wp: (b -> GTot (st_wp a))) (s: Type0) (rel: preorder s) (p: st_post s a) (s0: s) =
forall x. wp x s rel p s0
false
IMST.fst
IMST.st_wp'
val st_wp' : a: Type -> s: Type0 -> Type
let st_wp' (a:Type) (s:Type0) = st_post s a -> Tot (st_pre s)
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 108, "start_col": 0, "start_line": 107 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0) unfold let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0 unfold let st_stronger (a:Type) (wp1:st_wp a) (wp2:st_wp a) = forall (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) . wp1 s rel p s0 ==> wp2 s rel p s0 unfold let st_close (a:Type) (b:Type) (wp:(b -> GTot (st_wp a))) (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) = forall x. wp x s rel p s0 unfold let st_trivial (a:Type) (wp:st_wp a) = forall s rel s0. wp s rel (fun _ _ -> True) s0 new_effect { IMST : result:Type -> wp:st_wp result -> Effect with //repr = s:Type0 -> preorder s -> s -> M (a * s) // - pi-types currently not supported by DM4F //repr' = s:Type0 -> rel:preorder s -> s0:s -> M (a * s1:s{rel s0 s1}) // - pi-types currently not supported by DM4F; // refinement types also currently not supported by DM4F return_wp = st_return ; bind_wp = st_bind ; if_then_else = st_if_then_else ; ite_wp = st_ite ; stronger = st_stronger ; close_wp = st_close ; trivial = st_trivial } // For effects where subtyping parameters is sound, e.g., // // exn:Type -> exns:set exn -> M (either a e:exn{mem e exns}) // // there is also the problem of needing to subtype postconditions according to the chosen (subset) order on exns. // // The precise typing would (highly likely) be needed to ensure that reification/reflection are sound. (* Standard lifting *) unfold let lift_div_imst (a:Type) (wp:pure_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = wp (fun x -> post x s0) sub_effect DIV ~> IMST = lift_div_imst (* Non-indexed MST WPs and syntactic sugar for writing effect indices *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> s: Type0 -> Type
Prims.Tot
[ "total" ]
[]
[ "IMST.st_post", "IMST.st_pre" ]
[]
false
false
false
true
true
let st_wp' (a: Type) (s: Type0) =
st_post s a -> Tot (st_pre s)
false
FStar.Int128.fst
FStar.Int128.logor
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z))
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z))
let logor x y = Mk (logor (v x) (v y))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 63, "start_col": 0, "start_line": 63 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1 let add a b = Mk (add (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int128.t -> y: FStar.Int128.t -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "FStar.Int128.Mk", "FStar.Int.logor", "FStar.Int128.n", "FStar.Int128.v" ]
[]
false
false
false
false
false
let logor x y =
Mk (logor (v x) (v y))
false
IMST.fst
IMST.nat_rel'
val nat_rel':relation nat
val nat_rel':relation nat
let nat_rel' : relation nat = fun i j -> i <= j
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 134, "start_col": 0, "start_line": 133 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0) unfold let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0 unfold let st_stronger (a:Type) (wp1:st_wp a) (wp2:st_wp a) = forall (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) . wp1 s rel p s0 ==> wp2 s rel p s0 unfold let st_close (a:Type) (b:Type) (wp:(b -> GTot (st_wp a))) (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) = forall x. wp x s rel p s0 unfold let st_trivial (a:Type) (wp:st_wp a) = forall s rel s0. wp s rel (fun _ _ -> True) s0 new_effect { IMST : result:Type -> wp:st_wp result -> Effect with //repr = s:Type0 -> preorder s -> s -> M (a * s) // - pi-types currently not supported by DM4F //repr' = s:Type0 -> rel:preorder s -> s0:s -> M (a * s1:s{rel s0 s1}) // - pi-types currently not supported by DM4F; // refinement types also currently not supported by DM4F return_wp = st_return ; bind_wp = st_bind ; if_then_else = st_if_then_else ; ite_wp = st_ite ; stronger = st_stronger ; close_wp = st_close ; trivial = st_trivial } // For effects where subtyping parameters is sound, e.g., // // exn:Type -> exns:set exn -> M (either a e:exn{mem e exns}) // // there is also the problem of needing to subtype postconditions according to the chosen (subset) order on exns. // // The precise typing would (highly likely) be needed to ensure that reification/reflection are sound. (* Standard lifting *) unfold let lift_div_imst (a:Type) (wp:pure_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = wp (fun x -> post x s0) sub_effect DIV ~> IMST = lift_div_imst (* Non-indexed MST WPs and syntactic sugar for writing effect indices *) let st_wp' (a:Type) (s:Type0) = st_post s a -> Tot (st_pre s) unfold let (><) (#a:Type) (sr:(s:Type0 & preorder s)) (wp:st_wp' a (dfst sr)) : st_wp a = fun s rel post s0 -> s == dfst sr /\ (forall x y . rel x y <==> dsnd sr x y) /\ wp post s0 (* Standard, but now state-and-preorder indexed get, put, witness, and recall actions *) assume val get (#s:Type0) (#rel:preorder s) (_:unit) : IMST s ((|s , rel|) >< (fun p s0 -> p s0 s0)) assume val put (#s:Type0) (#rel:preorder s) (s1:s) : IMST unit ((|s , rel|) >< (fun p s0 -> rel s0 s1 /\ p () s1)) let witnessed (#s:Type) (#rel:preorder s) (p:predicate s) :Type0 = W.witnessed rel p assume val witness (#s:Type) (#rel:preorder s) (q:predicate s) : IMST unit ((|s , rel|) >< (fun p s0 -> stable q rel /\ q s0 /\ (witnessed #s #rel q ==> p () s0))) assume val recall (#s:Type) (#rel:preorder s) (q:predicate s) : IMST unit ((|s , rel|) >< (fun p s0 -> stable q rel /\ witnessed #s #rel q /\ (q s0 ==> p () s0))) (* Some sample code *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Preorder.relation Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
false
let nat_rel':relation nat =
fun i j -> i <= j
false
IMST.fst
IMST.witnessed
val witnessed (#s: Type) (#rel: preorder s) (p: predicate s) : Type0
val witnessed (#s: Type) (#rel: preorder s) (p: predicate s) : Type0
let witnessed (#s:Type) (#rel:preorder s) (p:predicate s) :Type0 = W.witnessed rel p
{ "file_name": "examples/indexed_effects/IMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 84, "end_line": 121, "start_col": 0, "start_line": 121 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module IMST (* A proof-of-concept example of indexed effects (the state-and-preorder indexed MST effect) encoded using standard F* WP calculi *) open FStar.Preorder module W = FStar.Monotonic.Witnessed (* The state-and-preorder indexed MST effect; defined explicitly rather than via DM4F due to the pi-types used in it *) //s is at a fixed universe level (here #u0) because because otherwise sub_effect complains about being too universe polymorphic let st_pre (s:Type0) = s -> GTot Type0 let st_post' (s:Type0) (a:Type) (pre:Type) = a -> (_:s{pre}) -> GTot Type0 let st_post (s:Type0) (a:Type) = st_post_h' s a True let st_wp (a:Type) = s:Type0 -> (preorder s) -> st_post_h s a -> Tot (st_pre_h s) unfold let st_return (a:Type) (x:a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall v. v == x ==> post v s0 unfold let st_bind (a:Type) (b:Type) (wp1:st_wp a) (wp2: (a -> Tot (st_wp b))) (s:Type0) (rel:preorder s) (post:st_post s b) (s0:s) = wp1 s rel (fun x s1 -> wp2 x s rel post s1) s0 unfold let st_if_then_else (a:Type) (p:Type) (wp_then:st_wp a) (wp_else:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = l_ITE p (wp_then s rel post s0) (wp_else s rel post s0) unfold let st_ite (a:Type) (wp:st_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = forall (k:st_post s a). (forall (x:a) (s1:s).{:pattern (guard_free (k x s1))} post x s1 ==> k x s1) ==> wp s rel k s0 unfold let st_stronger (a:Type) (wp1:st_wp a) (wp2:st_wp a) = forall (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) . wp1 s rel p s0 ==> wp2 s rel p s0 unfold let st_close (a:Type) (b:Type) (wp:(b -> GTot (st_wp a))) (s:Type0) (rel:preorder s) (p:st_post s a) (s0:s) = forall x. wp x s rel p s0 unfold let st_trivial (a:Type) (wp:st_wp a) = forall s rel s0. wp s rel (fun _ _ -> True) s0 new_effect { IMST : result:Type -> wp:st_wp result -> Effect with //repr = s:Type0 -> preorder s -> s -> M (a * s) // - pi-types currently not supported by DM4F //repr' = s:Type0 -> rel:preorder s -> s0:s -> M (a * s1:s{rel s0 s1}) // - pi-types currently not supported by DM4F; // refinement types also currently not supported by DM4F return_wp = st_return ; bind_wp = st_bind ; if_then_else = st_if_then_else ; ite_wp = st_ite ; stronger = st_stronger ; close_wp = st_close ; trivial = st_trivial } // For effects where subtyping parameters is sound, e.g., // // exn:Type -> exns:set exn -> M (either a e:exn{mem e exns}) // // there is also the problem of needing to subtype postconditions according to the chosen (subset) order on exns. // // The precise typing would (highly likely) be needed to ensure that reification/reflection are sound. (* Standard lifting *) unfold let lift_div_imst (a:Type) (wp:pure_wp a) (s:Type0) (rel:preorder s) (post:st_post s a) (s0:s) = wp (fun x -> post x s0) sub_effect DIV ~> IMST = lift_div_imst (* Non-indexed MST WPs and syntactic sugar for writing effect indices *) let st_wp' (a:Type) (s:Type0) = st_post s a -> Tot (st_pre s) unfold let (><) (#a:Type) (sr:(s:Type0 & preorder s)) (wp:st_wp' a (dfst sr)) : st_wp a = fun s rel post s0 -> s == dfst sr /\ (forall x y . rel x y <==> dsnd sr x y) /\ wp post s0 (* Standard, but now state-and-preorder indexed get, put, witness, and recall actions *) assume val get (#s:Type0) (#rel:preorder s) (_:unit) : IMST s ((|s , rel|) >< (fun p s0 -> p s0 s0)) assume val put (#s:Type0) (#rel:preorder s) (s1:s) : IMST unit ((|s , rel|) >< (fun p s0 -> rel s0 s1 /\ p () s1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.Witnessed.fsti.checked" ], "interface_file": false, "source_file": "IMST.fst" }
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.Preorder.predicate s -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.Preorder.predicate", "FStar.Monotonic.Witnessed.witnessed" ]
[]
false
false
false
true
true
let witnessed (#s: Type) (#rel: preorder s) (p: predicate s) : Type0 =
W.witnessed rel p
false
FStar.Int128.fst
FStar.Int128.logxor
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z))
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z))
let logxor x y = Mk (logxor (v x) (v y))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 61, "start_col": 0, "start_line": 61 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1 let add a b = Mk (add (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int128.t -> y: FStar.Int128.t -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "FStar.Int128.Mk", "FStar.Int.logxor", "FStar.Int128.n", "FStar.Int128.v" ]
[]
false
false
false
false
false
let logxor x y =
Mk (logxor (v x) (v y))
false
FStar.Int128.fst
FStar.Int128.logand
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z))
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z))
let logand x y = Mk (logand (v x) (v y))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 59, "start_col": 0, "start_line": 59 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1 let add a b = Mk (add (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int128.t -> y: FStar.Int128.t -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "FStar.Int128.Mk", "FStar.Int.logand", "FStar.Int128.n", "FStar.Int128.v" ]
[]
false
false
false
false
false
let logand x y =
Mk (logand (v x) (v y))
false
FStar.Int128.fst
FStar.Int128.shift_right
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (0 <= v a /\ UInt32.v s < n)) (ensures (fun c -> FStar.Int.shift_right (v a) (UInt32.v s) = v c))
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (0 <= v a /\ UInt32.v s < n)) (ensures (fun c -> FStar.Int.shift_right (v a) (UInt32.v s) = v c))
let shift_right a s = Mk (shift_right (v a) (UInt32.v s))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 67, "start_col": 0, "start_line": 67 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1 let add a b = Mk (add (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y)) let lognot x = Mk (lognot (v x))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Int128.t -> s: FStar.UInt32.t -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "FStar.UInt32.t", "FStar.Int128.Mk", "FStar.Int.shift_right", "FStar.Int128.n", "FStar.Int128.v", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let shift_right a s =
Mk (shift_right (v a) (UInt32.v s))
false
FStar.Int128.fst
FStar.Int128.lognot
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z))
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z))
let lognot x = Mk (lognot (v x))
{ "file_name": "ulib/FStar.Int128.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 65, "start_col": 0, "start_line": 65 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int128 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.Int open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly * a copy-paste of this module. *) type t : eqtype = | Mk: v:int_t n -> t let v x = x.v irreducible let int_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = int_to_t 0 let one = FStar.Math.Lemmas.pow2_lt_compat (n - 1) 1; int_to_t 1 let add a b = Mk (add (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": true, "source_file": "FStar.Int128.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Int128.t -> Prims.Pure FStar.Int128.t
Prims.Pure
[]
[]
[ "FStar.Int128.t", "FStar.Int128.Mk", "FStar.Int.lognot", "FStar.Int128.n", "FStar.Int128.v" ]
[]
false
false
false
false
false
let lognot x =
Mk (lognot (v x))
false